jd2007 Posted November 20, 2007 Share Posted November 20, 2007 how do i convert this string: "print('hello')" to act like this: <?php print('hello'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/78028-how-do-i-treat-a-string-as-a-code-to-be-executed-eg-below/ Share on other sites More sharing options...
~n[EO]n~ Posted November 20, 2007 Share Posted November 20, 2007 <?php print "print('hello')"; ?> another <?php print "\"print('hello')\""; ?> Quote Link to comment https://forums.phpfreaks.com/topic/78028-how-do-i-treat-a-string-as-a-code-to-be-executed-eg-below/#findComment-394914 Share on other sites More sharing options...
teng84 Posted November 20, 2007 Share Posted November 20, 2007 fumction printHello() { print 'hello'; } printHello(); Quote Link to comment https://forums.phpfreaks.com/topic/78028-how-do-i-treat-a-string-as-a-code-to-be-executed-eg-below/#findComment-394916 Share on other sites More sharing options...
jd2007 Posted November 20, 2007 Author Share Posted November 20, 2007 no...is there a way to make a string act like code like the Javascript function eval() ? Quote Link to comment https://forums.phpfreaks.com/topic/78028-how-do-i-treat-a-string-as-a-code-to-be-executed-eg-below/#findComment-394918 Share on other sites More sharing options...
teng84 Posted November 20, 2007 Share Posted November 20, 2007 php also has eval http://www.php.net/manual/en/function.eval.php Quote Link to comment https://forums.phpfreaks.com/topic/78028-how-do-i-treat-a-string-as-a-code-to-be-executed-eg-below/#findComment-394921 Share on other sites More sharing options...
jd2007 Posted November 20, 2007 Author Share Posted November 20, 2007 yeah...i just noticed in the manual...thanks Quote Link to comment https://forums.phpfreaks.com/topic/78028-how-do-i-treat-a-string-as-a-code-to-be-executed-eg-below/#findComment-394922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.