note 83588 added to function.is-null
| From: | strrevxc dot noxeh at ellij | Date: | Tue, 03 Jun 2008 12:42:21 +0000 |
| Subject: | note 83588 added to function.is-null | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140084@lists.php.net to get a copy of this message | ||
$var===NULL is much faster than is_null($var) (with the same result)
I did some benchmarking with 10 million iterations:
$a=null;
isset($a); Took: 1.71841216087s
$a==NULL; Took: 1.27205181122s
$a===NULL; Took: 1.2424390316s
is_null($a); Took: 3.70693397522s
$a=5;
isset($a); Took: 1.15165400505s
$a==NULL; Took: 1.41901302338s
$a===NULL; Took: 1.21655392647s
is_null($a); Took: 3.78501200676s
error_reporting(E_ALL&~E_NOTICE);
unset($a);
isset($a); Took: 1.51441502571s
$a==NULL; Took: 16.5414860249s
$a===NULL; Took: 16.1273870468s
is_null($a); Took: 23.1918480396s
Please note, that isset is only included because it gives a good performance in any case; HOWEVER
isset is NOT the same, or the opposite.
But you might be able to use isset() instead of null-checking.
You should not use is_null, except when you need a callback-function, or for conformity with is_int,
is_float, etc.
----
Server IP: 89.248.170.61
Probable Submitter: 82.93.241.107
----
Manual Page -- http://www.php.net/manual/en/function.is-null.php
Edit -- https://master.php.net/note/edit/83588
Del: integrated -- https://master.php.net/note/delete/83588/integrated
Del: useless -- https://master.php.net/note/delete/83588/useless
Del: bad code -- https://master.php.net/note/delete/83588/bad+code
Del: spam -- https://master.php.net/note/delete/83588/spam
Del: non-english -- https://master.php.net/note/delete/83588/non-english
Del: in docs -- https://master.php.net/note/delete/83588/in+docs
Del: other reasons-- https://master.php.net/note/delete/83588
Reject -- https://master.php.net/note/reject/83588
Search -- https://master.php.net/manage/user-notes.php