1

YES. I searched google for any answers.

I am learning php. I am trying to send email using some php code that has this eval line.

eval("job();");

But getting error:

eval()'d code on line 1

Any advice?

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390

2 Answers2

3

Don't use eval(). It's evil.

Assuming job is a function, you can call job() directly.

job();

If job() returns a value, you can assign it to use later, as needed.

$variable = job();
Community
  • 1
  • 1
Jason McCreary
  • 71,546
  • 23
  • 135
  • 174
0

Either call the function directly (if you know the name - judging by your snippet, you do) or, if you don't know what function needs to be called (it depends on a variable value or something, try using call_user_func or similar functions.
Also make sure the function exists with function_exists, for example

There's a whole bunch of functions, built into PHP that allows you not to use eval... just spend some time browsing through the docs

Elias Van Ootegem
  • 74,482
  • 9
  • 111
  • 149