3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Some { private $s; public function __construct($s) { $this->s = $s; } public function print() { echo $this->s . PHP_EOL; } } $s = new Some('done'); call_user_func(['Some', 'print'], $s);
Output for 7.0.0 - 7.3.0rc3
Deprecated: Non-static method Some::print() should not be called statically in /in/ZcCf7 on line 20 Fatal error: Uncaught Error: Using $this when not in object context in /in/ZcCf7:14 Stack trace: #0 /in/ZcCf7(20): Some::print(Object(Some)) #1 {main} thrown in /in/ZcCf7 on line 14
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: $this is null in /in/ZcCf7:-1 Stack trace: #0 /in/ZcCf7(-1): Some::print() #1 {main}
Process exited with code 255.
Output for hhvm-3.15.4 - 3.21.3
Fatal error: Uncaught Error: $this is null in /in/ZcCf7:14 Stack trace: #0 /in/ZcCf7(20): Some::print() #1 {main}
Process exited with code 255.
Output for 5.6.30
Parse error: syntax error, unexpected 'print' (T_PRINT), expecting identifier (T_STRING) in /in/ZcCf7 on line 12
Process exited with code 255.