bakunin Posted July 17, 2009 Share Posted July 17, 2009 Is there a function to parse php code within a string ? $string = '<?php echo 1+1 ?>';echo $string; i want it to echo 2 but it echo the unparse code "<?php echo 1+1 ?>"The problem i have is my code is in a string and is not parsed at the beginning of the file, the sample doesn't make sens i know, but in my real code, i have a reason why its in a string. :/ Link to comment Share on other sites More sharing options...
Ingolme Posted July 17, 2009 Share Posted July 17, 2009 eval() can do it: eval("echo 1+1"); But be very careful with it, if you allow users to put information into an eval() you could have your site hacked.There most likely is a better way to do things than having your code in a string. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.