context when calling non static method of class in a static way

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,

lets assume the following classes:

class Foo{

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

}

class Foobar{

public function callBarStatic()
	{
	Foo::bar();
	}

}

the following code results in the output "Foobar":

$obj = new Foobar();
$obj->callBarStatic();

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 (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux