#35509 [NEW]: string constant as array key has different behavior inside object
| From: | bill dot finn at sellingsource dot com | Date: | Thu, 01 Dec 2005 19:02:52 +0000 |
| Subject: | #35509 [NEW]: string constant as array key has different behavior inside object | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-89599@lists.php.net to get a copy of this message | ||
From: bill dot finn at sellingsource dot com
Operating system: Gentoo 2.6.9
PHP version: 6CVS-2005-12-01 (CVS)
PHP Bug Type: Arrays related
Bug description: string constant as array key has different behavior inside object
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
)
--
Edit bug report at http://bugs.php.net/?id=35509&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35509&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35509&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35509&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35509&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35509&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35509&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35509&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35509&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35509&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35509&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35509&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35509&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35509&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35509&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35509&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35509&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35509&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35509&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35509&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35509&r=mysqlcfg