bakunin Posted July 17, 2009 Report Share Posted July 17, 2009 (edited) 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. :/ Edited July 17, 2009 by bakunin Link to comment Share on other sites More sharing options...
Ingolme Posted July 17, 2009 Report Share Posted July 17, 2009 (edited) 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. Edited July 17, 2009 by Ingolme Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now