justravis Posted August 21, 2007 Share Posted August 21, 2007 Is there a way to do something like this? function name($name) { echo '<b>$name</b>'; } function abc($code) {javascript:void(0); Insert Code execute $code; } $code = "echo 'Name:'; name($name);"; abc($code); Quote Link to comment https://forums.phpfreaks.com/topic/66048-solved-php-variable-storing-functions/ Share on other sites More sharing options...
akitchin Posted August 21, 2007 Share Posted August 21, 2007 you'll want to use the eval() function, which will execute the string passed to it as though it's PHP code. keep in mind that it must be syntactically correct PHP code, and that you have to worry about quotes more than you would normally, as you have a second layer of interpretation going on. look in the php manual for more details. Quote Link to comment https://forums.phpfreaks.com/topic/66048-solved-php-variable-storing-functions/#findComment-330342 Share on other sites More sharing options...
justravis Posted August 21, 2007 Author Share Posted August 21, 2007 in this situation, i didnt even know the best keywords to use...how many search results you think returned when i used, "variable" & "function"? You helped IMMENSELY. eval() was just what I needed!! Indeed, you do have to keep escaping chars in mind. After about 20 min of confusion, I realized I didnt escape a $! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/66048-solved-php-variable-storing-functions/#findComment-330409 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.