RE: [PHP] Inheritance Question
| From: | Martin Towell | Date: | Wed, 09 Oct 2002 01:21:02 +0000 |
| Subject: | RE: [PHP] Inheritance Question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-119361@lists.php.net to get a copy of this message | ||
If you need to use variables that are stored in the object, then use
$this->jk();
If you're calling bar::do_something(); then $this wont be set, so you'll
need to use foo::jk() instead.
If you're calling jk() from an object, and you don't need to use any object
attributes, then either way would be okay... but I'd use $this->jk() anyway,
just to keep it all in the object (just in case...)
Martin
-----Original Message-----
From: Jarrad Kabral [mailto:JarradK@cordell.com.au]
Sent: Wednesday, October 09, 2002 11:18 AM
To: php-general@lists.php.net
Subject: [PHP] Inheritance Question
Hi all,
Was just wondering which is the better way to call an inherited method from
a child class?
Example:
class foo {
function jk() {
echo "In here!";
}
}
class bar extends foo {
function do_something() {
//Either this one...
$this->jk();
//Or this one...??
foo::jk();
}
}
Which is the best way? Is one a way a less memory intensive way than the
other?
Thanks in advance
Jarrad Kabral
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php