Jump to content


This topic is now archived and is closed to further replies.


eval() boolean statement

Recommended Posts

This has been bugging me.

I'm testing if a list of varibles (from a seperate list)I get from extract() from MySQL query is equal to "Y". Do a boolean compairason for each one (this is from a much larger thing). I'm calling this inside a function call

I keep getting "Parse error: parse error, unexpected $ in /home/thescriptwholedirectoryremoved.php(781) : eval()'d code on line 1"

here is the statement I use:

eval("return (\$" . $key . " == \"Y\")")

when I actually print the evaluated statement in PHP, it prints out as:
return ($carreq == "Y")

which is correct, but, eval gives me an error. please help

Share this post

Link to post
Share on other sites
thank you.

can you please explain why I got that error. earlier (before i posted here) I even took out the $ completly just cause I was getting pissed, and it still said "Unexpected $". How could it be unexpected, there was no $ at all.

edit: ahhh, it was the semicolon. I had no idea I would have to put one in there on a bool compairason. I don't for my other ones (of course for those, I was passing them alone as an argument), but appearently you have to for eval with a return statement. Thank you

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.