Home > Backend Development > PHP Tutorial > Why are the results of php, is_null and ==null different?

Why are the results of php, is_null and ==null different?

WBOY
Release: 2016-07-29 09:03:18
Original
1227 people have browsed it
is_null() function detects whether a variable is NULL
null is a special data type in PHP that represents a null value, which means that no value null (null value) is set for the variable
For example:
< ;?php
$str = '';
var_dump(is_null($str));
//returns false. Although the variable $str is assigned a value of empty, it is not of null type, so it returns false
var_dump($str == null);
//Return true, == only determines whether the values ​​are equal, not the type of data, so the empty
value of the variable $str is equal to null (equivalent to empty value)
var_dump($str === null);
//Return false, === not only determines whether the values ​​are equal, but also determines the type of data, so the empty
value of the variable $str (character string) is not equal to null (special data type)
?>

The above introduces php, why are the results of is_null and ==null different? , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template