<?php
class Foo
{
public function bar() {
echo isset($this) ? 'Instance' : 'Class', "\n";
}
}
// OK:
Foo::bar();
class Baz
{
public function test() {
Foo::bar();
}
}
// Take care:
$baz = new Baz;
$baz->test();
Fatal error: Uncaught Error: Non-static method Foo::bar() cannot be called statically in /in/mctMj:11
Stack trace:
#0 {main}
thrown in /in/mctMj on line 11
Process exited with code 255.
Deprecated: Non-static method Foo::bar() should not be called statically in /in/mctMj on line 11
Class
Deprecated: Non-static method Foo::bar() should not be called statically in /in/mctMj on line 16
Class
Output for 7.3.32 - 7.3.33
Class
Class
Output for 5.6.0 - 5.6.30
Strict Standards: Non-static method Foo::bar() should not be called statically in /in/mctMj on line 11
Class
Deprecated: Non-static method Foo::bar() should not be called statically, assuming $this from incompatible context in /in/mctMj on line 16
Instance
Strict Standards: Non-static method Foo::bar() should not be called statically in /in/mctMj on line 11
Class
Strict Standards: Non-static method Foo::bar() should not be called statically, assuming $this from incompatible context in /in/mctMj on line 16
Instance
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.2
Strict Standards: Non-static method Foo::bar() should not be called statically in /in/mctMj on line 11
Class
Instance
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/mctMj on line 4
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/mctMj on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/mctMj on line 4
Process exited with code 255.