note 89070 added to keyword.extends
| From: | AwaisKazimi at osu1 dot php dot net | Date: | Fri, 20 Feb 2009 08:26:11 +0000 |
| Subject: | note 89070 added to keyword.extends | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150883@lists.php.net to get a copy of this message | ||
Hi all,
I have read the contribution note of "tilman dot schroeder at gmx dot de" about printing
the parent class name.
I am basically Java Programmer, so I find that this problem basically deals with "type of the
object called" and not "the parent class of the method called".
in his example when the following lines of code are run:
1. $one=new one();
2. $one->two();
3. $one->three();
4. $one->one_get_parent_class_name();
5. $one->two_get_parent_class_name();
Then after line (3) the reference variable $one is referring to the "object of class
"one". Please refer to line (1) where the actual object of class one is being created.
Now, the reference variable $one calls the constructors/functions of class two and three because
they are the parent classes and the their functions are visible to this reference variable. But
remember $one is referring to the object of class "one" and the object never forgets its
class. So no matter where in the whole program you ask $one about his parent. He will only answer
"two"(i.e. no matter from which position you are calling get_parent_class($this), $this
only means "the instance" or "the object"). When ever you refer to the object
$one variable is referring to by using $this, the object will only tell you "Hey, I belong to
the class one and my parent is class two".
Remember: Object never forgets its "type"... Thanks
----
Server IP: 64.71.164.2
Probable Submitter: 58.65.148.149
----
Manual Page -- http://www.php.net/manual/en/keyword.extends.php
Edit -- https://master.php.net/note/edit/89070
Del: integrated -- https://master.php.net/note/delete/89070/integrated
Del: useless -- https://master.php.net/note/delete/89070/useless
Del: bad code -- https://master.php.net/note/delete/89070/bad+code
Del: spam -- https://master.php.net/note/delete/89070/spam
Del: non-english -- https://master.php.net/note/delete/89070/non-english
Del: in docs -- https://master.php.net/note/delete/89070/in+docs
Del: other reasons-- https://master.php.net/note/delete/89070
Reject -- https://master.php.net/note/reject/89070
Search -- https://master.php.net/manage/user-notes.php