The Little Guy Posted October 20, 2008 Share Posted October 20, 2008 I have this: eval("echo '<h1>'.$calc.'</h1>';"); and it gives me this: Parse error: syntax error, unexpected T_DNUMBER, expecting ',' or ';' in /home/.marble/ryannaddy/dudeel.com/results/toolsCalculator.php(18) : eval()'d code on line 1 Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/ Share on other sites More sharing options...
F1Fan Posted October 20, 2008 Share Posted October 20, 2008 Do you get the same thing with this? eval('echo "<h1>".$calc."</h1>";'); Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/#findComment-670106 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 is there a reason you are eval()ing the code? what is the value of $calc? remember, the value of $calc will be substituted before the eval. Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/#findComment-670107 Share on other sites More sharing options...
The Little Guy Posted October 20, 2008 Author Share Posted October 20, 2008 ah... got it! eval("echo '<h1>'.($calc).'</h1>';"); Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/#findComment-670111 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 any reason for the eval instead of just: echo '<h1>'.($calc).'</h1>'; Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/#findComment-670116 Share on other sites More sharing options...
The Little Guy Posted October 20, 2008 Author Share Posted October 20, 2008 yes, because if the user types in 2+2, it displays 2+2, using the eval it displays 4 Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/#findComment-670117 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 ah. well, just be careful on security there since you are giving the user control to run ANY php code Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/#findComment-670121 Share on other sites More sharing options...
The Little Guy Posted October 20, 2008 Author Share Posted October 20, 2008 Im trying to write something that will remove php functions/code unless it is a math function Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/#findComment-670148 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 hence the question in the other post....gotchya Link to comment https://forums.phpfreaks.com/topic/129251-solved-parse-error/#findComment-670150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.