Isset() VS Empty() VS Is_null() | Drupal 8

Isset() VS Empty() VS Is_null()

Submitted by editor on Thu, 09/01/2016 - 13:23
Question

What are the different between isset(), !empty(), !is_null() ?

Those are three functions allow you to determine the nature of a variable, with a bit different.

 

Comparison table

$value gettype($value) isset($value) !empty($value) !is_null($value)
0 integer TRUE - TRUE
NULL NULL - - -
FALSE boolean TRUE - TRUE
$undefined NULL - - -
"" string TRUE - TRUE
TRUE boolean TRUE TRUE TRUE
1 integer TRUE TRUE TRUE
"TXT" string TRUE TRUE TRUE

More details  : http://php.net/manual/en/types.comparisons.php

Tags

Add new comment