note 115692 added to function.empty

From: Date: Tue, 09 Sep 2014 20:37:14 +0000
Subject: note 115692 added to function.empty
Groups: php.notes 
Request: Send a blank email to php-notes+get-200399@lists.php.net to get a copy of this message
If you want to use empty() to evaluate an expression (not a variable), and you don't have PHP 5.5+, you can do it by wrapping the call to empty in a function, like so: <?php function is_empty($var) { return empty($var); } ?> Then you can do something like <?php if(is_empty(NULL)) { /* ... */ } ?> without issue, since the local variable $var is being tested rather than the expression in the function call itself. ---- Server IP: 72.52.91.14 Probable Submitter: 70.88.203.198 ---- Manual Page -- http://php.net/manual/en/function.empty.php Edit -- https://master.php.net/note/edit/115692 Del: integrated -- https://master.php.net/note/delete/115692/integrated Del: useless -- https://master.php.net/note/delete/115692/useless Del: bad code -- https://master.php.net/note/delete/115692/bad+code Del: spam -- https://master.php.net/note/delete/115692/spam Del: non-english -- https://master.php.net/note/delete/115692/non-english Del: in docs -- https://master.php.net/note/delete/115692/in+docs Del: other reasons-- https://master.php.net/note/delete/115692 Reject -- https://master.php.net/note/reject/115692 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200399) next »