Static array with boolean indexes
| Bug #30862 | Static array with boolean indexes | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2004-11-22 16:49 UTC | Modified: | 2005-02-12 17:40 UTC |
|
||||||||||
| From: | melnikow at hotbox dot ru | Assigned: | helly (profile) | |||||||||||
| Status: | Closed | Package: | Arrays related | |||||||||||
| PHP Version: | 5.0.3 | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-11-22 22:36 UTC] derick@php.net
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
[2005-02-12 17:40 UTC] helly@php.net