|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-08-08 02:36 UTC] laruence@php.net
[2012-08-08 07:10 UTC] julien at palard dot fr
[2012-09-04 17:54 UTC] ajf at ajf dot me
[2013-07-30 19:21 UTC] mike@php.net
-Package: Output Control
+Package: *General Issues
[2014-05-28 09:37 UTC] julien at palard dot fr
[2015-06-08 20:50 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2015-06-08 20:50 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 04:00:01 2025 UTC |
Description: ------------ Error reported for invalid [] access seems inconsistent : echo NULL["bar"] -> Parse error echo []["bar"] -> Parse error $foo = NULL; echo $foo["bar"] -> Fails silently $foo = []; echo $foo["bar"] -> Notice: Undefined index class Bar {} ; $foo = new Bar(); echo $foo["bar"]; -> PHP Fatal error I whish : []["bar"] to trigger Notice: Undefined index NULL["bar"] to trigger something catcheable with set_error_handler $foo = NULL; $foo["bar"] to trigger a catcheable Notice. Test script: --------------- /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); echo []["bar"];' /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); echo NULL["bar"];' /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); $foo = NULL; $foo["bar"];' /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); $foo = []; $foo["bar"];' /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); class Bar {} ; $foo = new Bar(); echo $foo["bar"];' Expected result: ---------------- At least get a Notice on : $foo = NULL; echo $foo["bar"]; Actual result: -------------- Fails silently.