3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if (defined('HHVM_VERSION')) { exit('*HHVM skipped*'); } function myErrorHandler($errno, $errstr, $errfile, $errline) { if ($errno == E_NOTICE && in_array($errstr, array( 'Undefined variable: undefined', 'Undefined variable: undefined', ), true)) { echo "\n"; echo "Caught a Notice: Undefined variable: undefined in $errfile on line $errline\n"; return true; } if ($errno == E_WARNING && in_array($errstr, array( 'current() expects parameter 1 to be array, null given', 'current(): Passed variable is not an array or object', 'current() [http://www.php.net/function.current]: Passed variable is not an array or object', ), true)) { echo "\n"; echo "(caught the warning about null not being an array in $errfile on line $errline)\n"; return true; } return false; } set_error_handler('myErrorHandler'); current($undefined); // will emit a notice if current() takes its parameter by value
Output for 4.4.1, 7.0.0 - 7.3.0rc3
Caught a Notice: Undefined variable: undefined in /in/365VC on line 33 (caught the warning about null not being an array in /in/365VC on line 33)
Output for hhvm-3.10.1 - 3.17.3
*HHVM skipped*
Output for 4.3.0 - 4.4.0, 4.4.2 - 5.0.5, 5.1.1 - 5.6.30
(caught the warning about null not being an array in /in/365VC on line 33)
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/365VC on line 33
Process exited with code 255.