3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public function fooMethod() { if (isset($this)) { echo get_class($this); } else { echo "no \$this"; } $class = __CLASS__; if ($this instanceof $class) { echo "instance of $class"; } else { echo "not instance of $class"; } } } class Bar { function barMethod() { Foo::fooMethod(); } } $bar = new Bar; $bar->barMethod();
based on gZpeu
Output for 7.1.0 - 7.2.0
Deprecated: Non-static method Foo::fooMethod() should not be called statically in /in/l9npe on line 22 no $this Fatal error: Uncaught Error: Using $this when not in object context in /in/l9npe:12 Stack trace: #0 /in/l9npe(22): Foo::fooMethod() #1 /in/l9npe(27): Bar->barMethod() #2 {main} thrown in /in/l9npe on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Non-static method Foo::fooMethod() should not be called statically in /in/l9npe on line 22 no $this Notice: Undefined variable: this in /in/l9npe on line 12 not instance of Foo
Output for 5.6.8 - 5.6.28
Deprecated: Non-static method Foo::fooMethod() should not be called statically, assuming $this from incompatible context in /in/l9npe on line 22 Barnot instance of Foo
Output for 5.3.18 - 5.5.35
Strict Standards: Non-static method Foo::fooMethod() should not be called statically, assuming $this from incompatible context in /in/l9npe on line 22 Barnot instance of Foo