PHP Classes, Calling Parent Methods
Submitted by johnk on Thu, 02/03/2005 - 12:21.
This is a followup to [PHP Constructors, Cascading Them].
This example just shows how to call the parent class constructor, and then call the parent class function. (I used this code to experiment with different ways to create the Base object.)
class Base {
var $x = 'object exists';
function Base()
{
print "Base called.";
}
function foo()
{
print "Base::foo $this->x";
}
}
class Ext extends Base
{
function Ext()
{
parent::Base();
}
function foo()
{
parent::foo();
}
}
$s = new Ext();
$s->foo();

