What does static
mean?
I know public
means that it can be accessed from outside the class, and private
only from inside the class…
An example: when use the static
keyword, we cannot use $this
class Foo {
private $foo='private';
private function priv_func() {
echo 'priv_method';
}
public static function get() {
echo $this->foo;
$this->priv_func();
}
}
$obj = new Foo();
$obj->get();
Fatal error: Using $this when not in object context in (…)