Home  >  Article  >  Backend Development  >  今日犯2了 当永记 PHP TRUE == 2

今日犯2了 当永记 PHP TRUE == 2

WBOY
WBOYOriginal
2016-06-13 12:41:50730browse

今天犯2了 当永记 PHP TRUE == 2

今天同事测试 投票功能 始终报已投过票的提示,仔细检查了下代码,也没有发现问题出在哪里?

?

最后一行行的排查才发现 原来是 bool == 整数 这个问题

?

$str=" ";

var_dump( empty($str)? );

exit;

?


$str = "1";
var_dump($str[0]);
$str = implode('|',$str);
//var_dump($str);


exit;

$a = 1==1;
$b = 2 == $a;

var_dump($b);
br( "\$b = " . $b );

var_dump(TRUE == 2);


exit;

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