| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2004-09-21 12:31 UTC] guth at fiifo dot u-psud dot fr
 Description:
------------
hello,
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:
---------------
<?
define("ROOT", $_SERVER['DOCUMENT_ROOT']);
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...
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 13:00:02 2025 UTC | 
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 }