Click to See Complete Forum and Search --> : doubt about the classes & objects and how they used to call the member functions


aniruddha
11-21-2005, 01:19 AM
hi,

i have following classes

class a
{
var x;
}

class b extends a
{

function init(){}

function somthing()
{
$this->x->init() ; // this is the what i need help for
}
}


at the commented point the $this is default object but what about variable x
i.e. $this -> x

i got error Call to a member function Init() on a non-object

can sombody explain me what this is?

Weedpacket
11-21-2005, 04:52 AM
$this->x refers to the property named "x" in this object. $this->x->init() means "call the init() method of the object stored in the 'x' property". if $this->x doesn't contain an object, you'd get the error message you wrote.

aniruddha
11-21-2005, 05:36 AM
$this->x->init()

or is it should be $this->$x->init()

thorpe
11-21-2005, 06:34 AM
or is it should be $this->$x->init()

no. properties of a class do not need $.

aniruddha
11-21-2005, 06:50 AM
i read your given url
thanx for that
it is really useful for newones like me