php echo inside if statement [duplicate]
Possible Duplicate:
echo inside if loop
I am trying to evaluate strings like "0>0.1","0<0.2" etc. suppose $string = "0>0.1" and i write if($string) it is always evaluating it to true since it is a non-empty 开发者_运维技巧string so i tried this way if(echo $string) and this time i am getting an error saying that i cannot echo inside if
You're looking for the eval() function.
if ( eval( $string ) ) {
}
http://php.net/eval
You need to be using eval
. Of course, this is very, very dangerous, so use it with caution.
精彩评论