note 71292 added to function.empty
| From: | tomi dot kaistila at sha dot quessir dot net | Date: | Tue, 21 Nov 2006 12:13:02 +0000 |
| Subject: | note 71292 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119937@lists.php.net to get a copy of this message | ||
It's good to also note that empty() can only be used on variables. Although this is clearly
said in the documentation, it is easy to forget it and try to directly pass a return value to it
from a function.
e.g.
<?php
include 'class.whois.php';
$whois = new whois();
if(!empty($whois->getWhoami())) {
echo "Could not find you.";
}
?>
This will produce a fatal error enigmatically saying, "Can't use method return value in
write context..."
----
Server IP: 80.81.171.181
Probable Submitter: 84.250.46.16
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- https://master.php.net/note/edit/71292
Del: integrated -- https://master.php.net/note/delete/71292/integrated
Del: useless -- https://master.php.net/note/delete/71292/useless
Del: bad code -- https://master.php.net/note/delete/71292/bad+code
Del: spam -- https://master.php.net/note/delete/71292/spam
Del: non-english -- https://master.php.net/note/delete/71292/non-english
Del: in docs -- https://master.php.net/note/delete/71292/in+docs
Del: other reasons-- https://master.php.net/note/delete/71292
Reject -- https://master.php.net/note/reject/71292
Search -- https://master.php.net/manage/user-notes.php