#43213 [Opn->Bgs]: Unable to define distinct class constants
| From: | derick@php.net | Date: | Sun, 11 Nov 2007 14:58:15 +0000 |
| Subject: | #43213 [Opn->Bgs]: Unable to define distinct class constants | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119447@lists.php.net to get a copy of this message | ||
ID: 43213
Updated by: derick@php.net
Reported By: uli dot staerk at globalways dot net
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
PHP Version: 5.2.4
New Comment:
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
.
Previous Comments:
------------------------------------------------------------------------
[2007-11-07 17:56:38] uli dot staerk at globalways dot net
So there is no difference beween class constants and (common script)
constants?
------------------------------------------------------------------------
[2007-11-07 16:22:11] carsten_sttgt at gmx dot de
You can found the answer here:
http://de.php.net/manual/en/reserved.php
| You cannot use any of the following words (PHP Keywords)
| as constants, class names, function or method names.
("array" is one of them)
Regards,
Carsten
------------------------------------------------------------------------
[2007-11-07 16:09:10] uli dot staerk at globalways dot net
Description:
------------
You can define class constants like:
class foo {
const bar = "baz";
}
But if the constant-name is array, it does not work.
Reproduce code:
---------------
<?php
class Test {
const Array = "array";
}
?>
Expected result:
----------------
It should work ;)
Actual result:
--------------
Parse error: syntax error, unexpected T_ARRAY, expecting T_STRING in
test.php on line 4
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43213&edit=1