From: kevin at happycactus dot nl
Operating system: Windows Server 2012 Standard
PHP version: 5.4.10
Package: Variables related
Bug Type: Feature/Change Request
Bug description:Class constant assignment doesn't make sense
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 bug report at https://bugs.php.net/bug.php?id=63959&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=63959&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=63959&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=63959&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63959&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63959&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63959&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63959&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63959&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63959&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63959&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63959&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63959&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63959&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63959&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63959&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63959&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63959&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63959&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63959&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63959&r=mysqlcfg