Problems with eval

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oohkumar
Forum Newbie
Posts: 2
Joined: Fri Feb 20, 2004 7:01 pm

Problems with eval

Post by oohkumar »

I'm trying to get Vbulletin code to work properly.

I'm having a problem with the eval function in the admin/options.php file in vbulletin.

eval ("echo \"$setting[optioncode]\";");

produces this error:

"Parse error: parse error, expecting `','' or `';'' in /usr/local/apache/htdocs/vbulletin/admin/options.php(72) : eval()'d code on line 2"

If I change the inner quote marks to singles:

eval ("echo '$setting[optioncode]';");

then I lose the error message but some of the source code html does not print correctly, for instance it prints out some php code where instead there should be html such as:

<select name=\"setting[$setting[settingid]]\">

Any idea on how to get the eval function working properly so that I no longer get error messages and it prints out html correctly.

Thanks,

oohkumar
User avatar
Albright
Forum Newbie
Posts: 20
Joined: Sat Sep 13, 2003 8:03 pm
Contact:

Post by Albright »

So what do you want echo'd? "$setting[optioncode]", or the value of $setting['optioncode'] ?

If it's the latter, try this. Note how the key to $setting[] is set apart by quotes.

eval ("echo '".$setting['optioncode']."';");

But, call me silly, but why is eval() being used in this way? Why not just

echo $setting['optioncode'];

?
Post Reply