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:[EMAIL PROTECTED]]
Sent: Wednesday, October 09, 2002 11:18 AM
To: [EMAIL PROTECTED]
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to