Home >Backend Development >PHP Tutorial >PHP中0和空的区别详解

PHP中0和空的区别详解

WBOY
WBOYOriginal
2016-06-20 13:04:251651browse

作为一个合格的php程序员,一些基础知识是必须要知道的,例如0和空的区别,关于这个区别。

下面就通过几个实例进行简单的分析,其中的道理,只可意会,不可言传,读者可以自己去慢慢体会了。

<span style="font-size: 14px;"><?php</span><br />$test=0;<br /><br />if($test==''){<br />echo '<br />在php中,0即为空'; //被输出<br />}<br /><br />if($test===''){<br />echo '<br />在php中,0即为空'; //不被输出<br />}<br /><br />if($test==NULL){<br />echo '<br />在php中,0即为空'; //被输出<br />}<br /><br />if($test===NULL){<br />echo '<br />在php中,0即为空'; //不被输出<br />}<br /><br />if($test==false){<br />echo '<br />在php中,0即为空'; //被输出<br />}<br /><br />if($test===false){<br />echo '<br />在php中,0即为空'; //不被输出<br />}<br /><br />?>


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