|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #30177 Allow concatenating in class constant values
Submitted: 2004-09-21 12:31 UTC Modified: 2014-03-05 21:20 UTC
Avg. Score:4.4 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:1 (20.0%)
From: guth at fiifo dot u-psud dot fr Assigned: requinix (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: * OS: *
Private report: No CVE-ID: None
 [2004-09-21 12:31 UTC] guth at fiifo dot u-psud dot fr

const is too restrictive in PHP.

I think it could be a good idea that the following code worked as expected.

If the constant is not defined, PHP could print a NOTICE and use the name of the constant instead.

Reproduce code:


class FIIFO {

	const PATH = ROOT."/path/to/this/class";


Expected result:
As PATH is a constant,

(FIIFO::PATH == "/www/path/to/this/class") for example.

Actual result:
A parse error...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-28 12:46 UTC]
-Summary: Change for const +Summary: Allow concatenating in constant values -Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: Linux (mandrake 10) +Operating System: * -PHP Version: 5.0.1 +PHP Version: *
 [2010-12-29 12:23 UTC]
-Summary: Allow concatenating in constant values +Summary: Allow concatenating in class constant values
 [2013-07-04 00:44 UTC] minchuk dot john at gmail dot com
Is this a bug or by design?  This produces the same error.  

        define("ASDF", "5678");

        $qwer = "1234" . ASDF;          //works fine

        $dude = new dude();             //errors here

        class dude {
                public $numbs = "1234" . ASDF;  //error
 [2014-03-05 20:32 UTC] narf at devilix dot net
This has been implemented in PHP 5.6
 [2014-03-05 21:20 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: requinix
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jan 20 14:01:23 2021 UTC