|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-08-11 20:42 UTC] php at abiusx dot com
[2017-01-12 11:04 UTC] peehaa@php.net
-Status: Open
+Status: Not a bug
[2017-01-12 11:04 UTC] peehaa@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
Description: ------------ Accessing an array will a null index is equal to accessing it with an empty string index, which is non-trivial and cause of many errors in applications. When a developer writes $a[$index]=5; They typically expect $index to be an index (regardless of type) and not null. But if it is null, the command still works and is equal to: $a[""]=5; //same as $a[null]=5; There is no trivial reason why null should cast to empty string, rather than say 0 or any other equivalent form. And this behavior typically should cause warnings or notices (although it breaks BC). Test script: --------------- $a=[]; $a[]=4; $a[null]=5; $a[]=6; var_dump($a); Expected result: ---------------- E_NOTICE, E_WARNING or $a[0]=5, but not $a[""]=5 Actual result: -------------- array(4) { [0]=> int(4) [""]=> int(5) [1]=> int(6) [2]=> int(7) }