|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-06-02 11:21 UTC] tgross at m-s dot de
Description: ------------ When trying to access an array using an undefined offset, PHP displays an Notice. However, when you access a boolean variable with any combination of the array operator [], PHP just returns NULL and displays no error message. Reproduce code: --------------- error_reporting (E_ALL); $a = false; var_dump ($a[5]); var_dump ($a['test'][-3]); Expected result: ---------------- PHP should display a Notice or a Warning. Actual result: -------------- PHP displays NULL NULL PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 17:00:01 2025 UTC |
Also it silently returns NULL when trying to pass a number as an array: ------------- <?php error_reporting(E_ALL); $int = 1; var_dump($int[100]); ------------- Expected: Error using integer as array Actual result: NULL I thing using a scalar value as an array is obviously user's error and it should be reported, e.g. with error message. Tested in PHP 5.6.7 (Debian), no error message reported. The same result if we use float instead of int. The same result if we use resource as array: $ php -r 'error_reporting(-1);$h = fopen("/etc/passwd", "r"); $x = $h[0];var_dump($x);' NULL