php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24569 Zend Engine 2 doesn't recognize access to indizes of class array constants
Submitted: 2003-07-09 16:57 UTC Modified: 2003-08-05 10:23 UTC
From: rele at gmx dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.0b2-dev OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rele at gmx dot de
New email:
PHP Version: OS:

 

 [2003-07-09 16:57 UTC] rele at gmx dot de
Description:
------------
The new per-class constants, introduced in PHP 5, don't allow to access array indizes.
If I define an array as a constant of a class and try to access the first index of this constant for example, the Zend Engine 2 gives a parse error.
Only index access on a variable, that points to this constant, works.

Reproduce code:
---------------
Class Example {
  const CATEGORIES = array('a', 'b');
}

$c=Example::CATEGORIES;
echo $c[0] . "\n";
echo Example::CATEGORIES[1] . "\n";


Expected result:
----------------
a
b


Actual result:
--------------
PHP Parse error:  parse error, unexpected '[' in example.php on line 8

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-09 17:28 UTC] sniper@php.net
Not sure if this is even supposed to work, but 
I can confirm this:

PHP Parse error:  parse error, expecting `','' or `';'' in /usr/src/web/php/php5/t.php on line 9

(strange, the error has changed? :)

 [2003-08-04 03:33 UTC] zeev@php.net
Not supposed to work.  Constants are a value/expression, you can only use the [] opreator on variables.
 [2003-08-05 10:23 UTC] sniper@php.net
Expected behaviour -> not bug -> bogus.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 21:01:33 2024 UTC