$object->methodReturnsObject()->doFoo(); parse error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

$object->methodReturnsObject()->doFoo(); parse error

Post by Nathaniel »

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/yogler/includes/controllers/page_controller.test.php on line 30

Doing:

Code: Select all

$method = $object->methodReturnsObject();
$method->doFoo();
works fine.

Why is that? Is there a workaround? I guess I could do $object->other_object->doFoo();...
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

Upgrade to PHP5 is unfortunatly the only answer.
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

Bah.

Thanks.
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

A spammer just hit this old blog post of mine: http://blog.casey-sweat.us/?p=38

Which reminded me of this topic. Kind of a hack, but might be of some use to you.
Post Reply