I have some code that is returned to my script in a variable. I need to execute it as PHP code but am nervous to use the eval
function. Here is the code that is generated in an include file:
/include.php:
$preLoadFields .= '$2 = new KoolDatePicker("datepicker");
$2->id="field_2";
$2->scriptFolder = "/KoolPHP";
/main.php
eval($preLoadFields);
Even when I try to run it using eval
, I get this error:
Parse error: syntax error, unexpected '2' (T_LNUMBER), expecting variable (T_VARIABLE) or '$'
Is there a better / safer way to do accomplish this? Thank you in advance!