there's a difference assigning a variable inside an eval or outside it as assignment?
eval ("\$variable = \"\$code\";")
$variable = eval($code)
I searched a lot for that information but I didn't find something about. Thanks.
there's a difference assigning a variable inside an eval or outside it as assignment?
eval ("\$variable = \"\$code\";")
$variable = eval($code)
I searched a lot for that information but I didn't find something about. Thanks.
Yes, there's a difference.
In the first case -
eval("\$variable = \"\$code\";");
- the variable$variable
will be declared, BUT its value will be a string of the code stored in vraiable$code
.Whereas the second case -
$variable = eval($code);
- will also declare a variable$variable
, BUT the value will be anything theeval
function returns (see docs) and it WILL process the code stored in variable$code
.