|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-12-01 21:08 UTC] tony2001@php.net
[2005-12-05 09:57 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 13 08:00:02 2025 UTC |
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 )