php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26869 (string) numeric constant as the key of static array mess up!
Submitted: 2004-01-11 04:47 UTC Modified: 2004-02-10 10:24 UTC
From: xuefer at 21cn dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-02-05 OS: *
Private report: No CVE-ID: None
 [2004-01-11 04:47 UTC] xuefer at 21cn dot com
Description:
------------
defined numeric constant but in string type
used in static $a = array(A => 1);
this produce array $a with a messed up key

Reproduce code:
---------------
under cygwin:
./php5/php.exe -n -r 'define("A", "1"); static $a=array(A => 1); var_dump($a); echo isset($a[A]); echo "\n";'


Expected result:
----------------
array(1) {
  [1]=>
  int(1)
}
1


Actual result:
--------------
array(1) {
  ["1"]=>
  int(1)
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-11 08:51 UTC] sniper@php.net
Slightly better test:

# php5 -r 'define("A", "1"); static $a=array(A => 1); var_dump($a); var_dump(isset($a[A]));'

(works fine with PHP4 btw..)

 [2004-02-10 10:24 UTC] zeev@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC