#43881 [Opn]: Example #1 for class constants shows error
| From: | paramount_98 at hotmail dot com | Date: | Thu, 17 Jan 2008 18:05:05 +0000 |
| Subject: | #43881 [Opn]: Example #1 for class constants shows error | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-448@lists.php.net to get a copy of this message | ||
ID: 43881
User updated by: paramount_98 at hotmail dot com
Reported By: paramount_98 at hotmail dot com
Status: Open
Bug Type: Documentation problem
Operating System: RHEL 5
-PHP Version: Irrelevant
+PHP Version: 5.2.5
New Comment:
This is referring to the documentation at
http://www.php.net/manual/en/language.oop5.constants.php
Previous Comments:
------------------------------------------------------------------------
[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