Eris Posted July 6, 2008 Share Posted July 6, 2008 Hi. This is a very simple fragment of code and I don't understand why it doesn't work. I'm probably doing smt very wrong. Plz help $line = 'array("Home", "Invite", "About", "Contacts");'; $array = eval($line); Quote Link to comment https://forums.phpfreaks.com/topic/113472-solved-eval/ Share on other sites More sharing options...
wildteen88 Posted July 6, 2008 Share Posted July 6, 2008 $array = eval($line); should be: eval("\$array = $line;"); Quote Link to comment https://forums.phpfreaks.com/topic/113472-solved-eval/#findComment-583047 Share on other sites More sharing options...
DarkWater Posted July 6, 2008 Share Posted July 6, 2008 First of all, eval() was just a typo from the creators of PHP. They meant to write evil(). So don't use it if you can help it. Secondly, it is doing exactly what you're telling it, it's creating an array, but you're not assigning it to anything inside the eval'd code. Go look up eval() on the PHP manual to see how to do it properly. $line = '$home = array("Home", "Invite", "About", "Contacts");'; eval($line); That should work, but why in the world would you use eval() there? =/ Quote Link to comment https://forums.phpfreaks.com/topic/113472-solved-eval/#findComment-583048 Share on other sites More sharing options...
Eris Posted July 6, 2008 Author Share Posted July 6, 2008 . Yep, I'm a noob in php. Thx Quote Link to comment https://forums.phpfreaks.com/topic/113472-solved-eval/#findComment-583051 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.