|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2004-11-22 16:49 UTC] melnikow at hotbox dot ru
 Description:
------------
With use of static array with boolean indexes inside the class methods occurs implicitly converting boolean to integer. 
Reproduce code:
---------------
<?php
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];
  }          
}
ClassA::test();
?>
Expected result:
----------------
This is TRUE 
This is TRUE
Actual result:
--------------
Notice: Undefined offset: 1 in ... on line 13 
This is TRUE
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 09:00:01 2025 UTC | 
This is actually valid, a shorter script: php -r 'class T{static $a=array(false=>"false",true=>"true");} print_r(T::$a);'