Object functions

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
tpaksu
Forum Newbie
Posts: 3
Joined: Sun May 04, 2008 6:09 am

Object functions

Post by tpaksu »

How can I create something like this in PHP4 ?

$obj->item->func()->item2

func returns also an obj.

When I use :
$var = $obj->item->func();
$var->item2

it works but how can I handle the code like the first one? In PHP5 its possible but I dont know how to do it in 4.

Thanks.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: Object functions

Post by yacahuma »

Why dont you use php5?
tpaksu
Forum Newbie
Posts: 3
Joined: Sun May 04, 2008 6:09 am

Re: Object functions

Post by tpaksu »

because my server doesnt support php5 and PLEASE dont give answers that is not related with the question. I asked if its possible or not. If you want more details, I wrote a XML parser class and I need that type of content handling.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Object functions

Post by Weirdan »

You can't. this:

Code: Select all

 
func()->member
 
is impossible in php4 and will lead to parse error.
On the other hand, construction like this is certainly valid:

Code: Select all

 
$html->body->div[4]->getContent()
 
tpaksu
Forum Newbie
Posts: 3
Joined: Sun May 04, 2008 6:09 am

Re: Object functions

Post by tpaksu »

Ok thank you.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: Object functions

Post by yacahuma »

sometime is good to ask to understand the environment you are in. Some people may not even know that they can upgrade. I ask to provide a better answer. But dont worry. I will know from you name that I should not even bother to help.
Post Reply