php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26050 Unable to use CONST vars in other CONST vars
Submitted: 2003-10-31 05:23 UTC Modified: 2003-10-31 08:40 UTC
From: kris dot hofmans at pandora dot be Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2003-10-31 (dev) OS: Linux 2.4.21
Private report: No CVE-ID: None
 [2003-10-31 05:23 UTC] kris dot hofmans at pandora dot be
Description:
------------
I have had code that has been running with php5-dev versions since July, wich now won't parse anymore.

I had declared a CONST in a class wich I used in another CONST below it, this now gives a: 
Parse error: parse error, expecting `','' or `';'' in /home/blacky/public_html/php5-dev/zen/ext/types.class.php on line 127

I am using PHP 5 Beta 2 (currently not in the list)

Reproduce code:
---------------
const NUMERIC		= '0-9';
const SPACE		= '\s';
const PUNCTUATION	= SPACE . '\.,;\:&"\'\?\!\(\)';
const ALPHA_LCASE	= 'a-z';
const E_ALPHA_LCASE	= ALPHA_LCASE . '??????????????????????';
const ALPHA_UCASE	= 'A-Z';
const E_ALPHA_UCASE	= ALPHA_UCASE . '??????????????????????';
const ALPHA		= ALPHA_LCASE . ALPHA_UCASE;
const E_ALPHA		= E_ALPHA_LCASE . E_ALPHA_UCASE;
const ALPHA_NUM		= ALPHA . NUMERIC;

Expected result:
----------------
I expect the behaviour to be something like.

const FOO = 'foo';
const BAR = 'bar';
const FOOBAR = FOO . BAR;

and that an echo FOOBAR would give me the string 'foobar'

Actual result:
--------------
Parse error: parse error, expecting `','' or `';'' in /home/blacky/public_html/php5-dev/zen/ext/types.class.php on line 127

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-31 08:40 UTC] sniper@php.net
"Head up! I'm reverting the patch which allows for expressions in constant declerations. Allowing the access of other constants in this code is flawed. We are reverting back to PHP 4's static scalars." -- Andi

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Feb 12 03:00:01 2026 UTC