#30862 [Asn->Csd]: Static array with boolean indexes
| From: | helly@php.net | Date: | Sat, 12 Feb 2005 16:40:13 +0000 |
| Subject: | #30862 [Asn->Csd]: Static array with boolean indexes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-73943@lists.php.net to get a copy of this message | ||
ID: 30862
Updated by: helly@php.net
Reported By: melnikow at hotbox dot ru
-Status: Assigned
+Status: Closed
Bug Type: Arrays related
Operating System: *
PHP Version: 5.0.3
Assigned To: helly
New Comment:
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
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-11-23 02:29:38] 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.
------------------------------------------------------------------------
[2004-11-22 22:36:08] 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-22 21:21:11] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
.
------------------------------------------------------------------------
[2004-11-22 16:49:47] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30862&edit=1