note 114536 deleted from language.types.null by cmb
| From: | cmb@php.net | Date: | Fri, 15 May 2015 19:07:12 +0000 |
| Subject: | note 114536 deleted from language.types.null by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-202541@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Note the following:
$test ='';
if (isset($test)){
echo 'Variable test exists';
}
if (empty($test)){ // same result as $test = ''
echo ' and is_empty';
}
if ($test == null){ // not the same result as is_null($test)
echo 'and is_null';
}
The result would be:
Variable test exists and is_empty and is_null
But for the following code...:
$test ='';
if (isset($test)){
echo 'Variable test exists';
}
if (empty($test)){ // same result as $test = ''
echo ' and is_empty';
}
if ($test === null){ // same result as is_null($test)
echo 'and is_null';
}
The result would be:
Variable test exists and is_empty
Therefore, for empty string variables, seems that 'empty' and 'null' has the
same value but different type.