#43881 [Opn->Bgs]: Example #1 for class constants shows error
| From: | felipe@php.net | Date: | Thu, 17 Jan 2008 18:15:24 +0000 |
| Subject: | #43881 [Opn->Bgs]: Example #1 for class constants shows error | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-449@lists.php.net to get a copy of this message | ||
ID: 43881
Updated by: felipe@php.net
Reported By: paramount_98 at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: RHEL 5
PHP Version: 5.2.5
New Comment:
Above on page:
"As of PHP 5.3.0, it's possible to reference the class using a
variable. Keywords like self, parent or static are not allowed in
dynamic class references."
Previous Comments:
------------------------------------------------------------------------
[2008-01-17 18:05:04] paramount_98 at hotmail dot com
This is referring to the documentation at
http://www.php.net/manual/en/language.oop5.constants.php
------------------------------------------------------------------------
[2008-01-17 18:04:21] paramount_98 at hotmail dot com
Description:
------------
Run example #1 on PHP 5.2.5 produces parse error.
Reproduce code:
---------------
<?php
class MyClass
{
const constant = 'constant value';
function showConstant() {
echo self::constant . "\n";
}
}
echo MyClass::constant . "\n";
$classname = "MyClass";
echo $classname::constant . "\n";
$class = new MyClass();
$class->showConstant();
echo $class::constant."\n";
?>
Expected result:
----------------
outputs 'constant value'
Actual result:
--------------
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting
',' or ';' in /www/mydomain.com/httpdocs/class-constant-test.php on line
14
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43881&edit=1