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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 05:01:34 2025 UTC