note 58675 added to function.empty
| From: | inerteismygmail dot comusername at osu1 dot php dot net | Date: | Fri, 11 Nov 2005 14:58:15 +0000 |
| Subject: | note 58675 added to function.empty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98428@lists.php.net to get a copy of this message | ||
empty() is about 10% faster than a comparision.
if (empty($var)) {
}
is faster than:
if ($var == '') {
}
YMMV, empty() also checks array and attributes, plus 0, and '' is kind a string with
nothing inside. But I was using '' and got a huge performance boost with empty().
PHP 4.3.10-15, Apache/2.0.54, Kernel 2.4.27-2-386.
----
Manual Page -- http://www.php.net/manual/en/function.empty.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58675
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58675&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58675&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58675&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58675&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58675&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58675&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58675&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58675&report=yes
Search -- http://master.php.net/manage/user-notes.php