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

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

WBOY
Release: 2016-06-13 13:16:41
Original
903 people have browsed it

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

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)返回假,用程序运算出来全部为真??

Copy after login



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

eval('return '. $item[$column_name] .$operation. $info. ';')
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template