php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43213 Unable to define distinct class constants
Submitted: 2007-11-07 16:09 UTC Modified: 2007-11-11 14:58 UTC
From: uli dot staerk at globalways dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.4 OS:
Private report: No CVE-ID: None
 [2007-11-07 16:09 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-07 16:22 UTC] 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 17:56 UTC] uli dot staerk at globalways dot net
So there is no difference beween class constants and (common script) constants?
 [2007-11-11 14:58 UTC] derick@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

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 10:01:30 2024 UTC