php !== null

This forum covers all minor versions of PHP 7
Post Reply
User avatar
Administrator
Site Admin
Posts: 1725
Joined: Thu Mar 22, 2018 10:19 am

php !== null

Post by Administrator » Fri May 18, 2018 10:36 am

The best way to check if a variable is not equal to null

Most Logical, And the fastest way

Code: Select all

if($variable !== NULL){
	/* NOT NULL */
}
You could use

Code: Select all

if(!is_null($var)){
	/* NOT NULL */
}
and then reverse the value by using ! BANG.

Post Reply