At 22:52 09.02.2003, Chris Hayes said:
--------------------[snip]--------------------
>At 22:49 9-2-2003, you wrote:
>>yes, you can call a static method on a class by specifying the class name,
>>then 2 colons and finally the function name:
>>
>>classname :: functionname([arg,.....])
>>
>>(of course properties can not be accessed by such methods)
>ah ok, cool
--------------------[snip]--------------------
With PHP you can also determine if your class method has been called via an
object instance, or class static, by checking the $this reference:
class foo {
function test() {
if (isset($this) && is_object($this) && get_class($this) == 'foo')
echo 'I am a foo object';
else
echo 'I have been called as a "static" method';
}
}
$foo = new foo();
foo::test();
$foo->test();
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php