By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,748 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,748 IT Pros & Developers. It's quick & easy.

method name exists, property value exists, calling method fails

P: n/a
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_class_methods($this->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
$whateverObjName->setName('Whatever'); 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?

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.