3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if (true){ set_error_handler(function($a, $b, $c, $d){ var_dump('error_handler', $a, $b, $c, $d); }); } $var = 1; try { $var->method(); // Throws an Error object in PHP 7. } catch (Error $e) { // Handle error var_dump('error', $e); } catch (Exception $e) { // Handle error var_dump('exception', $e); } ?>
based on qPmEj
Output for 7.0.0 - 7.2.0
string(5) "error" object(Error)#2 (7) { ["message":protected]=> string(45) "Call to a member function method() on integer" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/c4UaD" ["line":protected]=> int(11) ["trace":"Error":private]=> array(0) { } ["previous":"Error":private]=> NULL }
Output for 5.6.8 - 5.6.28
Fatal error: Call to a member function method() on integer in /in/c4UaD on line 11
Process exited with code 255.
Output for 5.3.20 - 5.5.35
Fatal error: Call to a member function method() on a non-object in /in/c4UaD on line 11
Process exited with code 255.