note 102524 added to language.types.null
| From: | contact at mullanaphy dot com | Date: | Fri, 18 Feb 2011 23:31:03 +0000 |
| Subject: | note 102524 added to language.types.null | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177131@lists.php.net to get a copy of this message | ||
In reply to poutri_j's post (albeit old) about an empty array() == NULL.
It's not that an empty array is considered null, its that both are considered FALSE in a
comparison. So:
<?php
$array = array();
if($array==NULL) echo '$array == NULL'; # Echos
if($array===NULL) echo '$array === NULL'; # Doesn't echo.
?>
This is as expected and something that all newcomers should pick up on. Link to PHP's great
reference on comparisons: http://php.net/manual/de/types.comparisons.php
----
Server IP: 69.147.83.197
Probable Submitter: 74.94.28.33
----
Manual Page -- http://www.php.net/manual/en/language.types.null.php
Edit -- https://master.php.net/note/edit/102524
Del: integrated -- https://master.php.net/note/delete/102524/integrated
Del: useless -- https://master.php.net/note/delete/102524/useless
Del: bad code -- https://master.php.net/note/delete/102524/bad+code
Del: spam -- https://master.php.net/note/delete/102524/spam
Del: non-english -- https://master.php.net/note/delete/102524/non-english
Del: in docs -- https://master.php.net/note/delete/102524/in+docs
Del: other reasons-- https://master.php.net/note/delete/102524
Reject -- https://master.php.net/note/reject/102524
Search -- https://master.php.net/manage/user-notes.php