note 114536 added to language.types.null

From: Date: Tue, 04 Mar 2014 18:05:44 +0000
Subject: note 114536 added to language.types.null
Groups: php.notes 
Request: Send a blank email to php-notes+get-198787@lists.php.net to get a copy of this message
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. ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/language.types.null.php Edit -- https://master.php.net/note/edit/114536 Del: integrated -- https://master.php.net/note/delete/114536/integrated Del: useless -- https://master.php.net/note/delete/114536/useless Del: bad code -- https://master.php.net/note/delete/114536/bad+code Del: spam -- https://master.php.net/note/delete/114536/spam Del: non-english -- https://master.php.net/note/delete/114536/non-english Del: in docs -- https://master.php.net/note/delete/114536/in+docs Del: other reasons-- https://master.php.net/note/delete/114536 Reject -- https://master.php.net/note/reject/114536 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198787) next »