3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Kitchen { private $value = 'cheese'; } $k = new Kitchen(); $m = function(){ var_dump($this); echo 'called me. Value is ' . $this->value; }; Closure::bind($m, $k, $k); $m();
Output for 7.1.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/rs7l2:13 Stack trace: #0 /in/rs7l2(19): {closure}() #1 {main} thrown in /in/rs7l2 on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.14
Notice: Undefined variable: this in /in/rs7l2 on line 13 NULL Fatal error: Uncaught Error: Using $this when not in object context in /in/rs7l2:14 Stack trace: #0 /in/rs7l2(19): {closure}() #1 {main} thrown in /in/rs7l2 on line 14
Process exited with code 255.
Output for hhvm-3.12.0
Notice: Undefined variable: this in /in/rs7l2 on line 13 NULL Fatal error: Uncaught Error: $this is null in /in/rs7l2:14 Stack trace: #0 /in/rs7l2(19): Closure$() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Notice: Undefined variable: this in /in/rs7l2 on line 13 NULL Fatal error: $this is null in /in/rs7l2 on line 14
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Notice: Undefined variable: this in /in/rs7l2 on line 13 NULL Fatal error: Using $this when not in object context in /in/rs7l2 on line 14
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Fatal error: Call to undefined method Closure::bind() in /in/rs7l2 on line 17
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/rs7l2 on line 12
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/rs7l2 on line 12
Process exited with code 255.
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/rs7l2 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/rs7l2 on line 5
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/rs7l2 on line 5
Process exited with code 255.