Req #63959 [Opn->Dup]: Class constant assignment doesn't make sense
| From: | aharvey@php.net | Date: | Fri, 11 Jan 2013 00:46:40 +0000 |
| Subject: | Req #63959 [Opn->Dup]: Class constant assignment doesn't make sense | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175944@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63959&edit=1
ID: 63959
Updated by: aharvey@php.net
Reported by: kevin at happycactus dot nl
Summary: Class constant assignment doesn't make sense
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
Package: Variables related
Operating System: Windows Server 2012 Standard
PHP Version: 5.4.10
Block user comment: N
Private report: N
New Comment:
Duplicate of request #30177.
Previous Comments:
------------------------------------------------------------------------
[2013-01-10 11:00:20] kevin at happycactus dot nl
Description:
------------
We have to work around certain unnecessary limitations regarding class constants.
See 'Test script' for complete details on what bothers me (and other PHP
developers)
Test script:
---------------
// Example 1: valid
const IMAGE_ROOT = '/www/public/img';
// Example 2: valid
define ('PUBLIC_ROOT', '/www/public');
define ('IMAGE_ROOT', PUBLIC_ROOT . '/img');
const FOO = IMAGE_ROOT;
// Example 3: invalid
define ('PUBLIC_ROOT', '/www/public');
const IMAGE_ROOT = PUBLIC_ROOT . '/img';
According to the manual:
"The value must be a constant expression, not (for example) a variable,
a property, a result of a mathematical operation, or a function call."
My question is: why is the concatenation of one or more CONSTANT values
prohibited in PHP? It doesn't have any added value, and even worse: makes
source code less readable because we have to clutter it with defined named constants or replace them
with static properties as means of a workaround.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63959&edit=1