note 124642 added to function.list
| From: | vike2000 at gmail dot com | Date: | Thu, 23 Jan 2020 15:49:19 +0000 |
| Subject: | note 124642 added to function.list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213948@lists.php.net to get a copy of this message | ||
Setting it like <?php list($var1,$varN) = null ?> does _not_ raise an E_NOTICE (or other
error) and afaics effectively equals an https://php.net/function.unset of $var1,$varN.
I note this as contrasting with the fact that PHP triggers an E_NOTICE about "Undefined
offset" "if there aren't enough array elements to fill the list()", as attow
documented for https://php.net/control-structures.foreach#control-structures.foreach.list
and here only noted in https://php.net/function.list#122951 by Mardaneus.
For completeness, a bash(1) (v5.0 or 4.3 on macos10.13) cli test producing the same result for all
my PHP-versions (installed via macports.org) follows. It's also tested with php7.3 using
bash5.0 on Debian10:
bash --noprofile --norc -c 'for php in php{{53..56},{70..73}};do for literal in
"array()" null;do echo -n $php â¦=$literal:&&$php -n -d error_reporting=E_ALL
-r "var_dump(list(\$var)=$literal);";done;done'
# Above produces the same result pairs per version from:
php53 â¦=array():
Notice: Undefined offset: 0 in Command line code on line 1
array(0) {
}
# ... to:
php73 â¦=null:NULL
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.195 (proxied: 188.148.206.216)
----
Manual Page -- http://php.net/manual/en/function.list.php
Edit -- https://master.php.net/note/edit/124642
Del: integrated -- https://master.php.net/note/delete/124642/integrated
Del: useless -- https://master.php.net/note/delete/124642/useless
Del: bad code -- https://master.php.net/note/delete/124642/bad+code
Del: spam -- https://master.php.net/note/delete/124642/spam
Del: non-english -- https://master.php.net/note/delete/124642/non-english
Del: in docs -- https://master.php.net/note/delete/124642/in+docs
Del: other reasons-- https://master.php.net/note/delete/124642
Reject -- https://master.php.net/note/reject/124642
Search -- https://master.php.net/manage/user-notes.php