note 19860 added to keyword.paamayim-nekudotayim
| From: | carl at php2 dot chek dot com | Date: | Wed, 13 Mar 2002 14:20:21 +0000 |
| Subject: | note 19860 added to keyword.paamayim-nekudotayim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27720@lists.php.net to get a copy of this message | ||
Note that if you have two classes, 'foo' and 'bar', and a function in foo called
with $instance_of_foo->func() calls bar::func2(), $this will be defined in func2, and it will
point at an object of class foo. In fact, you can redefine $this to point to an object of any class
before calling bar::func2() to have $this to be a reference to that object. This means that you
can't have functions that can be called either as static (::) or member(->), since you
won't be able to tell the difference. This is a quite unfortunate consequence of the
combination of references not containing any type information and it not being possible to call an
explicitly chosen base class member function (that is, if x extends y there's no clean way to
call y::f() on an object of class x (The unclean way is to assign $this to $instance_of_x, call
y::f(), and reset $this to its old value.)).
--
http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php
http://master.php.net/manage/user-notes.php?action=edit+19860
http://master.php.net/manage/user-notes.php?action=delete+19860
http://master.php.net/manage/user-notes.php?action=reject+19860