views:

44

answers:

1

I have a method which returns a class and want to call a method on it. Instead of

$theClass = $this->getClass();
$theClass->foo();

I would like to write

$this->getClass()->foo();

Is there a syntax for this as of PHP4?

This works:

$this->{$this->getClassName()}->foo();

But I would like to manipulate the class beforehand (I do this now in getClass()).

+1  A: 

Nope, it won't work in PHP4, this feature has been bettered in PHP5. I wonder why are you still using PHP4 :)

Sarfraz
I wondered the same thing as soon as I saw the php4 tag
Carson Myers
@Carson Myers: yeah it is strange people still using php4 :(
Sarfraz
I'm sad, too, but my company still uses PHP4 (and Apache 1.3 - and Kernel 2.4). ;-)Maybe someone else can come up with some fancy construct that allows me to write my statement in one line?
blinry
you're better off writing it on two lines. Just do one thing per line.
Carson Myers