3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private static $sfoo = 1; private $ifoo = 2; } $cl1 = static function() { return A::$sfoo; }; $cl2 = function() { return $this->ifoo; }; $bcl1 = $cl1->bindTo(new A(), 'A'); $bcl2 = $cl2->bindTo(null, 'A'); echo $bcl1(), "\n"; echo $bcl2(), "\n";
based on rljhc
Output for 7.0.0 - 7.2.0
Warning: Cannot bind an instance to a static closure in /in/M7ov6 on line 14 Fatal error: Uncaught Error: Function name must be a string in /in/M7ov6:16 Stack trace: #0 {main} thrown in /in/M7ov6 on line 16
Process exited with code 255.
Output for 5.4.11 - 5.6.28
Warning: Cannot bind an instance to a static closure in /in/M7ov6 on line 14 1 Fatal error: Using $this when not in object context in /in/M7ov6 on line 11
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_FUNCTION, expecting T_PAAMAYIM_NEKUDOTAYIM in /in/M7ov6 on line 7
Process exited with code 255.