note 74025 added to function.is-null

From: Date: Wed, 21 Mar 2007 10:27:58 +0000
Subject: note 74025 added to function.is-null
Groups: php.notes 
Request: Send a blank email to php-notes+get-124658@lists.php.net to get a copy of this message
As powderz comments below, "is_null() will return true if the variable has not been set". It will also trigger a notice-level message, like pretty much any use of an unset variable would. Much of the confusion observed comes from users suppressing or otherwise ignoring those messages. Best practice is to ensure that variables are set before using or examining their values - in this case, using isset(). empty() (the other function that tolerates unset variables) would not be suitable, since that doesn't distinguish between an unset variable and one that contains a null. There is a difference between an unset variable and null: a variable that has a null value is an entry in PHP's list of extant variables. An unset variable doesn't appear in the list. ---- Server IP: 202.89.36.242 Probable Submitter: 202.27.216.35 (proxied: 202.27.216.110) ---- Manual Page -- http://www.php.net/manual/en/function.is-null.php Edit -- https://master.php.net/note/edit/74025 Del: integrated -- https://master.php.net/note/delete/74025/integrated Del: useless -- https://master.php.net/note/delete/74025/useless Del: bad code -- https://master.php.net/note/delete/74025/bad+code Del: spam -- https://master.php.net/note/delete/74025/spam Del: non-english -- https://master.php.net/note/delete/74025/non-english Del: in docs -- https://master.php.net/note/delete/74025/in+docs Del: other reasons-- https://master.php.net/note/delete/74025 Reject -- https://master.php.net/note/reject/74025 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124658) next »