Re: Turning a string into a condition

From: Date: Thu, 16 Feb 2012 21:24:23 +0000
Subject: Re: Turning a string into a condition
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-316638@lists.php.net to get a copy of this message
On Thu, Feb 16, 2012 at 9:49 PM, Marc Guay <marc.guay@gmail.com> wrote: >> I just added the return statement and the semicolon, because the error was complaining >> about it not being a proper PHP statement basically. > > That's beautiful, thanks.  I just stumbled across a forum post that > said it wasn't possible and was about to give up for the day. > > Marc While it works, I'm a bit worried about how you're going to use this. If the data is from user input, then this is really dangerous (that's why there is a big fat warning on the eval man page). You can easily execute nasty commands with eval. If it is user input, then it would be much safer to do the parsing yourself. It shouldn't be that hard to parse this type of expressions. - Matijn - Matijn

« previous php.general (#316638) next »