note 81718 deleted from function.empty by cmb
| From: | cmb@php.net | Date: | Fri, 26 Apr 2019 16:57:04 +0000 |
| Subject: | note 81718 deleted from function.empty by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210682@lists.php.net to get a copy of this message | ||
Note Submitter: David from CodeXplorer
----
Mad Hampster did his test wrong. empty is NOT faster than a simple boolean check. The ONLY reason
to use empty() is for code readability. It is the same as an IF/ELSE check. But if you are dealing
with intermediate or higher level coders this function has no other benefit.
So, don't bother using EMPTY in the real world.
I ran an array with 5000 simple true/false values through four checks (both types twice) in case of
any gain one type might have by going first. These are my results generated one one page request.
(PHP5)
0.015328 Time EMPTY
0.014281 Time IF/ELSE
0.015239 Time EMPTY
0.013404 Time IF/ELSE
The page was accessed a couple times to reduce caching effects.