#24569 [Ver->Csd]: Zend Engine 2 doesn't recognize access to indizes of class array constants

From: Date: Mon, 04 Aug 2003 08:33:24 +0000
Subject: #24569 [Ver->Csd]: Zend Engine 2 doesn't recognize access to indizes of class array constants
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-45287@lists.php.net to get a copy of this message
ID: 24569 Updated by: zeev@php.net Reported By: rele at gmx dot de -Status: Verified +Status: Closed Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5.0.0b2-dev New Comment: Not supposed to work. Constants are a value/expression, you can only use the [] opreator on variables. Previous Comments: ------------------------------------------------------------------------ [2003-07-09 17:28:24] 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-07-09 16:57:33] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24569&edit=1

« previous php.bugs (#45287) next »