开发者

php echo inside if statement [duplicate]

开发者 https://www.devze.com 2023-02-25 19:29 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: echo inside if loop I am trying to evaluate strings like
This question already has answers here: Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号