0

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()).

blinry
  • 4,746
  • 4
  • 26
  • 31

1 Answers1

1

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

Sarfraz
  • 377,238
  • 77
  • 533
  • 578
  • @Carson Myers: yeah it is strange people still using php4 :( – Sarfraz Feb 19 '10 at 07:42
  • 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 Feb 19 '10 at 12:25
  • 1
    you're better off writing it on two lines. Just do one thing per line. – Carson Myers Feb 20 '10 at 22:21