Home  >  Article  >  Backend Development  >  The difference between 0 and null in PHP

The difference between 0 and null in PHP

小云云
小云云Original
2017-11-22 16:56:081767browse

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==&#39;&#39;){
echo &#39;<br />在php中,0即为空&#39;; //被输出
}
if($test===&#39;&#39;){
echo &#39;<br />在php中,0即为空&#39;; //不被输出
}
if($test==NULL){
echo &#39;<br />在php中,0即为空&#39;; //被输出
}
if($test===NULL){
echo &#39;<br />在php中,0即为空&#39;; //不被输出
}
if($test==false){
echo &#39;<br />在php中,0即为空&#39;; //被输出
}
if($test===false){
echo &#39;<br />在php中,0即为空&#39;; //不被输出
}
?>

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!

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