yes! at least my example works. i didn't test it any further; i doubt it is intended that way.

Simon Hilz

Am 22.05.2011 16:42, schrieb
        So without extending foo you can run bar in another class?

Richard L. Buskirk

-----Original Message-----
From: Simon Hilz []
Sent: Sunday, May 22, 2011 10:18 AM
Subject: [PHP] context when calling non static method of class in a static


lets assume the following classes:

class Foo{

public function bar()
        echo get_class($this);


class Foobar{

public function callBarStatic()


the following code results in the output "Foobar":

$obj = new Foobar();

That means that the static call of bar() is executed in the context of
Foobar. Is this behavior deliberate? If so, it would open a great way of
object composition patterns. But only if it will be retained in future
versions :) (i've tested with 5.3.5)

Simon Hilz

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to