I have a class object I am calling in another class:
class Stuff {
var $myObj;
function Stuff($myObj) {
$this->myObj = $myObj;
}
function doStuff() {
print_r(get_cla ss_methods($thi s->myObj)); print_r("<P>");
print_r($this->myObj->name . "<P>");
print_r($this->myObj->getName() . "<P>");
}
}
The first "print_r" works just fine and shows a "getName" method in
the array of methods for object $this->myObj. The second "print_r"
works just fine and shows the property value that was set in a prior
$whateverObjNam e->setName('Whate ver'); the value comes up as
"Whatever". BUT the third print_r throws a nasty error "Member
function called on a non-object". What happened? How did it turn from
being a legitimate object to a NON-object in one line? Could someone
with some class experience point me in the right direction as far as
using "getter" functions of one object inside another object function?
Confused.
Thanx
Phil
class Stuff {
var $myObj;
function Stuff($myObj) {
$this->myObj = $myObj;
}
function doStuff() {
print_r(get_cla ss_methods($thi s->myObj)); print_r("<P>");
print_r($this->myObj->name . "<P>");
print_r($this->myObj->getName() . "<P>");
}
}
The first "print_r" works just fine and shows a "getName" method in
the array of methods for object $this->myObj. The second "print_r"
works just fine and shows the property value that was set in a prior
$whateverObjNam e->setName('Whate ver'); the value comes up as
"Whatever". BUT the third print_r throws a nasty error "Member
function called on a non-object". What happened? How did it turn from
being a legitimate object to a NON-object in one line? Could someone
with some class experience point me in the right direction as far as
using "getter" functions of one object inside another object function?
Confused.
Thanx
Phil