Home >Backend Development >PHP Tutorial >The difference between null, 0, and false in php updatedata false javascript:false async fals

The difference between null, 0, and false in php updatedata false javascript:false async fals

WBOY
WBOYOriginal
2016-07-29 08:52:061042browse

The

empty() function is used to determine whether a string is empty.

As long as the variable is 0, null, '', false, empty() will be judged to be true.

    $num1='';
    $num2=0;
    echo $num1==$num2;
    echo '<br/>';
    echo $num1===$num2 ? '1' : '0';

The result is:

not null false,false,false是什么意思,false函数,false怎么读,return false,false的反义词,true false,false的意思,true or false,false king,ture false什么意思,updatedata false,javascript:false,async fals

The reason is that variables in PHP are stored in C language structures. Empty strings, NULL, and false are all stored with a value of 0, and this structure There is a member variable like zend_uchartype;, which is used to save the type of the variable. The type of empty string is string, the type of NULL is NULL, and false is boolean. The === operator not only compares values, but also types.

Judge the empty string and 0 like this:

    $num1='';
    $num2=0;
    if(empty($num1) && $num1===''){
    	echo "true";
    }
    if(empty($num2) && $num2===0){
    	echo 'true';
    }
The result is:

not null false,false,false是什么意思,false函数,false怎么读,return false,false的反义词,true false,false的意思,true or false,false king,ture false什么意思,updatedata false,javascript:false,async fals

The above introduces the differences between null, 0, and false in PHP, including the content of false and null. I hope it will be helpful to friends who are interested in PHP tutorials.

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