Home > Article > Backend Development > The difference between 0 and null in PHP
For PHP beginners, they will encounter many problems during learning, so we must learn to summarize them. To be a qualified PHP programmer, you must know some basic knowledge, such as the difference between 0 and null. Regarding this difference, let's conduct a simple analysis through several examples. I hope everyone can learn from this simple explanation. Learn to think and summarize.
<?php $test=0; if($test==''){ echo '<br />在php中,0即为空'; //被输出 } if($test===''){ echo '<br />在php中,0即为空'; //不被输出 } if($test==NULL){ echo '<br />在php中,0即为空'; //被输出 } if($test===NULL){ echo '<br />在php中,0即为空'; //不被输出 } if($test==false){ echo '<br />在php中,0即为空'; //被输出 } if($test===false){ echo '<br />在php中,0即为空'; //不被输出 } ?>
The above is the difference between 0 and null in PHP. Although a few lines of code seem simple, they are still very useful in work. I hope it will be helpful to everyone.
Related recommendations:
How to use MySQL database to determine that the NULL result is 1?
In javascript, a discussion on whether null is equal to 0
Detailed explanation of NULL in MySQL
The above is the detailed content of The difference between 0 and null in PHP. For more information, please follow other related articles on the PHP Chinese website!