|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30862 Static array with boolean indexes
Submitted: 2004-11-22 16:49 UTC Modified: 2005-02-12 17:40 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: melnikow at hotbox dot ru Assigned: helly
Status: Closed Package: Arrays related
PHP Version: 5.0.3 OS: *
Private report: No CVE-ID:
 [2004-11-22 16:49 UTC] melnikow at hotbox dot ru
With use of static array with boolean indexes inside the class methods occurs implicitly converting boolean to integer. 

Reproduce code:
class ClassA
  public static $arr =
    array(FALSE => "This is FALSE",
          TRUE  => "This is TRUE");
  static public function test()
    $arr = array(FALSE => "This is FALSE",
                 TRUE  => "This is TRUE");
    echo self::$arr[TRUE];
    echo "<br>".$arr[TRUE];


Expected result:
This is TRUE 
This is TRUE

Actual result:
Notice: Undefined offset: 1 in ... on line 13 
This is TRUE


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-22 21:21 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

 [2004-11-22 22:36 UTC]
This is actually valid, a shorter script:
php -r 'class T{static $a=array(false=>"false",true=>"true");} print_r(T::$a);'

 [2004-11-23 02:29 UTC] melnikow at hotbox dot ru
Yes :) I agree, manual tells about implicitly converting, but there is no way to get access to array with any index of 0, 1, FALSE, TRUE.
 [2005-02-12 17:40 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 16:01:38 2015 UTC