note 90779 added to function.is-null

From: Date: Sat, 09 May 2009 15:47:45 +0000
Subject: note 90779 added to function.is-null
Groups: php.notes 
Request: Send a blank email to php-notes+get-154387@lists.php.net to get a copy of this message
A difference between "is_null" and "empty" is the following: "is_null" tests if an <i>expression</i> is null, while "empty" tests if a <i>variable</i> has null value or is undefined. This has small Experiment 1: <?php function test() { return null } var_dump(is_null(test()); // display "true" var_dump(empty(test()); // parse error, because "test()" is not a variable ?> Experiment 2: <?php var_dump(empty($an_undefined_variable)); // display "true" since "$an_undefined_variable" is not defined var_dump(is_null($an_undefined_variable); // display "false", but throw a notice because "$an_undefined_variable" is not defined. ?> ---- Server IP: 89.31.146.176 Probable Submitter: 213.103.152.224 ---- Manual Page -- http://www.php.net/manual/en/function.is-null.php Edit -- https://master.php.net/note/edit/90779 Del: integrated -- https://master.php.net/note/delete/90779/integrated Del: useless -- https://master.php.net/note/delete/90779/useless Del: bad code -- https://master.php.net/note/delete/90779/bad+code Del: spam -- https://master.php.net/note/delete/90779/spam Del: non-english -- https://master.php.net/note/delete/90779/non-english Del: in docs -- https://master.php.net/note/delete/90779/in+docs Del: other reasons-- https://master.php.net/note/delete/90779 Reject -- https://master.php.net/note/reject/90779 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154387) next »