Why is this legal in PHP?
<?php class Foo { public function test() { echo "hello "; } } Foo::test(); ?>
test() is a non-static function but I can access it without an instance.
It's legal, but generally frowned upon, until you reference $this in your statically called method which will throw a fatal error.
$this
2.1m questions
2.1m answers
60 comments
57.0k users