Posted by Ciaran on 05/03/06 17:20
Andy,
I think that 'self' will not do what you want, in this instance.
In PHP, 'self' always refers to the class in which it is used so in
your example code you will get a warning that A::TEST_CONST is not
defined when you try either $b->printConst() or $c->printConst().
This is very annoying behaviour, but there isn't a keyword in PHP5 that
refers to 'the current class' in the way you want it to. This is under
discussion for PHP6, and a new keyword apparently may or may not be
introduced - I'm hoping very much that it will!
See:
http://www.php.net/~derick/meeting-notes.html#late-static-binding-using-this-without-or-perhaps-with-a-different-name
[Back to original message]
|