#43881 [Asn->Csd]: Example #1 for class constants shows error

From: Date: Thu, 17 Jan 2008 19:06:24 +0000
Subject: #43881 [Asn->Csd]: Example #1 for class constants shows error
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-451@lists.php.net to get a copy of this message
ID: 43881 Updated by: colder@php.net Reported By: paramount_98 at hotmail dot com -Status: Assigned +Status: Closed Bug Type: Documentation problem Operating System: RHEL 5 PHP Version: 5.2.5 Assigned To: colder New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2008-01-17 18:18:17] bjori@php.net Examples requiring specific PHP versions should be commented as such. Etienne: Please fix all the examples (if more) referring to this feature (and LSB). ------------------------------------------------------------------------ [2008-01-17 18:15:22] felipe@php.net 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." ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#451) next »