note 126266 added to language.types.null
| From: | mattias at kregert dot se | Date: | Thu, 22 Jul 2021 19:57:37 +0000 |
| Subject: | note 126266 added to language.types.null | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216638@lists.php.net to get a copy of this message | ||
Note that NULL works like a magic object with any attribute you can name, but they are all NULL:
foreach ( [ null, null ] as $person ) {
$friends[] = [ 'Name'=>$person['name'],
'Phone'=>$person['cell'] ];
}
print_r($friends);
Array
(
[0] => Array
(
[Name] =>
[Phone] =>
)
[1] => Array
(
[Name] =>
[Phone] =>
)
)
This means that:
* NULL == NULL['foo']['bar']['whatever']
This can be slightly confusing if you accidentally slip a NULL into an array of other items.
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 78.108.52.23)
----
Manual Page -- https://php.net/manual/en/language.types.null.php
Edit -- https://main.php.net/note/edit/126266
Del: integrated -- https://main.php.net/note/delete/126266/integrated
Del: useless -- https://main.php.net/note/delete/126266/useless
Del: bad code -- https://main.php.net/note/delete/126266/bad+code
Del: spam -- https://main.php.net/note/delete/126266/spam
Del: non-english -- https://main.php.net/note/delete/126266/non-english
Del: in docs -- https://main.php.net/note/delete/126266/in+docs
Del: other reasons-- https://main.php.net/note/delete/126266
Reject -- https://main.php.net/note/reject/126266
Search -- https://main.php.net/manage/user-notes.php