#50068 [Bgs]: const problem
| From: | scottmac@php.net | Date: | Wed, 04 Nov 2009 01:44:24 +0000 |
| Subject: | #50068 [Bgs]: const problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-144230@lists.php.net to get a copy of this message | ||
ID: 50068
Updated by: scottmac@php.net
Reported By: jachym dot tousek at gmail dot com
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows 7
PHP Version: 5.3.1RC3
New Comment:
const is a compile time constant and only allows simple scalar values.
define is a constant resolved at runtime and it allows full expressions
when being defined.
Previous Comments:
------------------------------------------------------------------------
[2009-11-03 22:26:15] jachym dot tousek at gmail dot com
Well i've checked
[http://www.php.net/manual/en/language.constants.syntax.php] and also
updated from 5.3.0 to 5.3.1RC3 before sending this report, but there is
nothing about const name = 'value'; being different from
define('name','value'); and i can not understand it even now.
------------------------------------------------------------------------
[2009-11-03 21:46:58] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
------------------------------------------------------------------------
[2009-11-03 21:11:32] ksingla@php.net
I think this behavior is by design. const expressions are evaluated at
compile time. So only few operations are supported in a const expression
and string concatenation is not one of those. I could repro this in PHP
5.2 (after putting it under a class).
------------------------------------------------------------------------
[2009-11-03 20:16:44] jachym dot tousek at gmail dot com
Description:
------------
const is not working
Reproduce code:
---------------
<?php
const ROOT_DIR = __DIR__ . '/..'; //parse error
<?php
define('ROOT_DIR',__DIR__ . '/..'); //works fine
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50068&edit=1