Home >Backend Development >PHP Tutorial > 关于运算符的有关问题。为毛这样

关于运算符的有关问题。为毛这样

WBOY
WBOYOriginal
2016-06-13 13:16:41907browse

关于运算符的问题。为毛这样?

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
if($item[$column_name] .$operation. $info)
        {
            echo $item[$column_name] .$operation. $info;echo '=====true';echo '<br>';
            return true;
        }else{
            echo $item[$column_name] .$operation. $info;echo '=====false';echo '<br>';
            return false;
        }
输出:
508205462=505765854=====true
10>1234567=====true
201234567)返回假,用程序运算出来全部为真??




------解决方案--------------------
因为有“.”,所以你那些变量当做字符串连接起来了
如果想让他们当做表达式运算,需用 eval 函数

eval('return '. $item[$column_name] .$operation. $info. ';')
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn