Page 1 of 1
Object functions
Posted: Sun May 04, 2008 6:14 am
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.
Re: Object functions
Posted: Sun May 04, 2008 9:51 am
by yacahuma
Why dont you use php5?
Re: Object functions
Posted: Sun May 04, 2008 9:54 am
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.
Re: Object functions
Posted: Sun May 04, 2008 10:12 am
by Weirdan
You can't. this:
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()
Re: Object functions
Posted: Sun May 04, 2008 10:13 am
by tpaksu
Ok thank you.
Re: Object functions
Posted: Sun May 04, 2008 10:17 am
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.