Req #30177 [Com]: Allow concatenating in class constant values

From: Date: Wed, 05 Mar 2014 20:32:00 +0000
Subject: Req #30177 [Com]: Allow concatenating in class constant values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184538@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=30177&edit=1

 ID:                 30177
 Comment by:         narf at devilix dot net
 Reported by:        guth at fiifo dot u-psud dot fr
 Summary:            Allow concatenating in class constant values
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   *
 PHP Version:        *
 Block user comment: N
 Private report:     N

 New Comment:

This has been implemented in PHP 5.6

https://wiki.php.net/rfc/const_scalar_exprs


Previous Comments:
------------------------------------------------------------------------
[2013-07-04 00:44:33] 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
        }

------------------------------------------------------------------------
[2013-01-11 00:46:40] aharvey@php.net

Related To: Bug #63959

------------------------------------------------------------------------
[2004-09-21 12:31:00] 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...


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=30177&edit=1


Thread (4 messages)

« previous php.bugs (#184538) next »