string constant as array key has different behavior inside object
| Bug #35509 | string constant as array key has different behavior inside object | ||||
|---|---|---|---|---|---|
| Submitted: | 2005-12-01 20:02 UTC | Modified: | 2005-12-05 15:13 UTC | ||
| From: | bill dot finn at sellingsource dot com | Assigned: | dmitry (profile) | ||
| Status: | Closed | Package: | Arrays related | ||
| PHP Version: | 5CVS-2005-12-01 (CVS) | OS: | Gentoo 2.6.9 | ||
| Private report: | No | CVE-ID: | None | ||
[2005-12-01 20:02 UTC] bill dot finn at sellingsource dot com
Description:
------------
When using a constant of '01' as an array key inside of a class, it converts the key to the integer 1. Outside of a class, it leaves it as '01'.
Reproduce code:
---------------
class mytest
{
const classConstant = '01';
private $classArray = array( mytest::classConstant => 'value' );
public function __construct()
{
print_r($this->classArray);
}
}
$classtest = new mytest();
define( "normalConstant", '01' );
$normalArray = array( normalConstant => 'value' );
print_r($normalArray);
Expected result:
----------------
Array
(
[01] => value
)
Array
(
[01] => value
)
Actual result:
--------------
Array
(
[1] => value
)
Array
(
[01] => value
)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits