ChrisB: Methoden Aufruf

Beitrag lesen

Hi,

in PHP kann man ja Funktionen so aufrufen:

$function = "hello_world";
$function();

Ja, kann man.

geht so was auch mit Klassen??

Was jetzt, mit Klassen - oder Methoden?

Also

$this->function = "hello_world";
$this->function();

Das ginge natuerlich genauso wie oben - wenn man es denn genauso wie oben machen wuerde.

$methodenName = "hello_world";
$this->$methodenName();

MfG ChrisB

--
„This is the author's opinion, not necessarily that of Starbucks.“