note 47804 deleted from language.oop5.constants by sean
| From: | sean@php.net | Date: | Wed, 01 Dec 2004 02:11:14 +0000 |
| Subject: | note 47804 deleted from language.oop5.constants by sean | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81207@lists.php.net to get a copy of this message | ||
Note Submitter: Norman Clarke <norman at dontblink dot com>
----
Perhaps I'm overlooking something, but in 5.0.2 it appears there's no way to access class
constants when the class name is a variable. Example:
class MyClass {
const A_CONSTANT = 62;
public $a_variable = 62;
}
$className = "MyClass";
$object = new $className;
// this will output "62."
echo $object->a_variable . "\n";
/*
* this will cause the dreaded "unexpected T_PAAMAYIM_NEKUDOTAYIM"
* parse error
*/
echo $object::A_CONSTANT;
----
Reason: bad code