#43213 [Opn]: Unable to define distinct class constants
| From: | uli dot staerk at globalways dot net | Date: | Wed, 07 Nov 2007 17:56:38 +0000 |
| Subject: | #43213 [Opn]: Unable to define distinct class constants | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119348@lists.php.net to get a copy of this message | ||
ID: 43213
User updated by: uli dot staerk at globalways dot net
Reported By: uli dot staerk at globalways dot net
Status: Open
Bug Type: Scripting Engine problem
PHP Version: 5.2.4
New Comment:
So there is no difference beween class constants and (common script)
constants?
Previous Comments:
------------------------------------------------------------------------
[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