3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private $func = null; public function __construct($func) { $this->func = $func; } public function exec() { $this->func(); } } $a = new A(function() { echo 'works'; }); $a->exec();
based on Auho0
Output for 7.0.0 - 7.2.12
Fatal error: Uncaught Error: Call to undefined method A::func() in /in/R67L7:11 Stack trace: #0 /in/R67L7(19): A->exec() #1 {main} thrown in /in/R67L7 on line 11
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Call to undefined method A::func() in /in/R67L7:-1 Stack trace: #0 /in/R67L7(-1): A->exec() #1 {main}
Process exited with code 255.
Output for hhvm-3.11.1 - 3.21.3
Fatal error: Uncaught Error: Call to undefined method A::func() in /in/R67L7:11 Stack trace: #0 /in/R67L7(19): A->exec() #1 {main}
Process exited with code 255.
Output for 5.3.21 - 5.6.38, hhvm-3.10.1
Fatal error: Call to undefined method A::func() in /in/R67L7 on line 11
Process exited with code 255.