Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP is_null() and ==null [duplicate]

Tags:

php

null

In PHP, what is the difference between is_null and ==null in PHP? What are the qualifications for both to return true?

like image 999
kel_ff0080 Avatar asked Mar 12 '12 17:03

kel_ff0080


People also ask

Is null or === null PHP?

$x === nullNull is a special data type in PHP which can have only one value that is NULL. A variable of data type NULL is a variable that has no value assigned to it. Any variable can be empty by setting the value NULL to the variable.

Is equal to null in PHP?

The is_null() function checks whether a variable is NULL or not. This function returns true (1) if the variable is NULL, otherwise it returns false/nothing.

How do you set a variable to null in PHP?

In PHP, a variable with no value is said to be of null data type. Such a variable has a value defined as NULL. A variable can be explicitly assigned NULL or its value been set to null by using unset() function.

Is null true or false PHP?

NULL essentially means a variable has no value assigned to it; false is a valid Boolean value, 0 is a valid integer value, and PHP has some fairly ugly conversions between 0 , "0" , "" , and false . Show activity on this post. Null is nothing, False is a bit, and 0 is (probably) 32 bits.


1 Answers

is_null is the same as === null. Both return true when a variable is null (or unset).

Note that I'm using === and not ==. === compares type as well as value.

like image 63
Rocket Hazmat Avatar answered Sep 17 '22 13:09

Rocket Hazmat