php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48560 E_STRICT does not report error if booleans or ints are used as arrays
Submitted: 2009-06-15 15:20 UTC Modified: 2015-05-12 21:06 UTC
Votes:9
Avg. Score:3.8 ± 0.9
Reproduced:7 of 7 (100.0%)
Same Version:3 (42.9%)
Same OS:2 (28.6%)
From: mk at gigacodes dot de Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: 5.*, 6 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mk at gigacodes dot de
New email:
PHP Version: OS:

 

 [2009-06-15 15:20 UTC] mk at gigacodes dot de
Description:
------------
when setting error_reporting to E_ALL|E_STRICT accessing undefined offsets in array $arr is reported. However if $arr is a boolean, int or null there is no error reported



Reproduce code:
---------------
<?
error_reporting(E_ALL | E_NOTICE | E_STRICT);

#reports undefined variable
echo $xxx;

#does not report error
$xxx = false;
echo $xxx[1];

#reports undefinied offset
$xxx = array();
echo $xxx[1];
?>


Expected result:
----------------
I expect to see 3 errors 



Actual result:
--------------
instead i see only 2:
Notice: Undefined variable: xxx
Notice: Undefined offset: 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-18 14:59 UTC] gwynne@php.net
Verified on Darwin9 with 5.3CVS-2009-06-18
 [2009-07-06 18:55 UTC] niczak at gmail dot com
After performing the same tests in the original post I get the same results.  Only 2 errors reported as opposed to the expected 3.  PHP Version 5.2.8 on a Solaris box.
 [2011-01-27 15:03 UTC] bugs dot php dot net at moesen dot nu
Same behaviour on Mac OS X, "PHP 5.3.5 (cli) (built: Jan 24 2011 12:53:02)":

PHP Notice:  Undefined variable: xxx in Command line code on line 4
PHP Notice:  Undefined offset: 1 in Command line code on line 12

Isn't this a dupe of "bug #37676 – using Array access operator [] on boolean variable does not show Notice"?
 [2015-05-12 21:06 UTC] cmb@php.net
-Status: Verified +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2015-05-12 21:06 UTC] cmb@php.net
Indeed, that is a duplicate of bug #37676, and the same issue has been reported several times since this report (requinix has gathered some of these in bug #65484).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC