3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $previous = NULL; function call() { var_dump( __FUNCTION__ ); } set_error_handler( 'call' ); trigger_error( 'some message 1', E_USER_NOTICE ); $previous = set_error_handler( function() use( $previous ) { // note that previous is null, because of association sequence var_dump( __FUNCTION__ ); } ); trigger_error( 'some message 2', E_USER_NOTICE ); var_dump( set_error_handler( NULL ) ); trigger_error( 'some message 3', E_USER_NOTICE );
Output for 5.5.0 - 5.6.28, 7.0.0 - 7.1.0
string(4) "call" string(9) "{closure}" object(Closure)#1 (1) { ["static"]=> array(1) { ["previous"]=> NULL } } Notice: some message 3 in /in/vmGgL on line 14
Output for hhvm-3.12.0
string(4) "call" string(9) "{closure}" object(Closure$call;1252929942$501ce95fa4cf41f13f2164dd20fc2a06$)#1 (1) { ["static"]=> array(1) { ["previous"]=> NULL } } Warning: Invalid argument: function: not string, closure, or array in /in/vmGgL on line 14
Output for hhvm-3.10.0
string(4) "call" string(9) "{closure}" object(Closure$call;1252929942$34ba1a8dbf0fd30279bb30edd235f6$)#1 (1) { ["static"]=> array(1) { ["previous"]=> NULL } } Warning: Invalid argument: function: not string, closure, or array in /in/vmGgL on line 14
Output for 5.3.0 - 5.4.45
string(4) "call" string(9) "{closure}" string(9) "{closure}" NULL string(9) "{closure}"
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/vmGgL on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/vmGgL on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/vmGgL on line 8
Process exited with code 255.