php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6662 array keys of type real not allowed?
Submitted: 2000-09-11 22:06 UTC Modified: 2001-09-24 03:29 UTC
From: jeroen at polder dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.2 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jeroen at polder dot net
New email:
PHP Version: OS:

 

 [2000-09-11 22:06 UTC] jeroen at polder dot net
It seems that array keys of type real are not allowed in class declaration:

class MyClass {
 var $a = array( 1.5=>1, 3.5=>2, 7.5=>5, 99=>10);
 ...
}

Results in only one item 99=>10 in array.

Above is accepted in PHP3.

Workaround:

 var $a = array( '1.5'=>1, '3.5'=>2, '7.5'=>5, '99'=>10);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-16 17:00 UTC] stas@php.net
Float keys don't work, the variable gets converted to integer. This, however, doesn't work with array initializers - this should be fixed.
 [2001-05-06 11:38 UTC] zeev@php.net
Fixed in the CVS - thanks for your report!
 [2001-09-24 03:29 UTC] jeroen@php.net
From the docs (by heart): in object initializers only constant scalar experssions are allowed, no arrays, objects, or expressions, only simple int/float/etc.

That's incorrect thus? Should be 'only constant values', because arrays and 'new Object()' are allowed? Or arrays only?

IMO, it should be the case, but I don't know wether it's supported in ZE1.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 02:01:28 2025 UTC