oop - How can I tell if a function is being called statically in PHP? -
possible duplicate:
how tell whether i’m static or object?
let's have fooclass
bar()
method. inside of bar()
method, there way tell if it's being called statically or not, can treat these 2 cases differently?
fooclass::bar(); $baz = new fooclass(); $baz->bar();
class fooclass { function bar() { if ( isset( $this ) && get_class($this) == __class__ ) { echo "not static"; } else { echo "static"; } } } fooclass::bar(); $baz = new fooclass(); $baz->bar();
Comments
Post a Comment