3v4l.org

run code in 300+ PHP versions simultaneously
<?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); } ?>
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
string(5) "error" object(Error)#2 (7) { ["message":protected]=> string(41) "Call to a member function method() on int" ["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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 string(5) "error" object(Error)#2 (7) { ["message":protected]=> string(41) "Call to a member function method() on int" ["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 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33
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.0 - 5.6.38
Fatal error: Call to a member function method() on integer in /in/c4UaD on line 11
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Fatal error: Call to a member function method() on a non-object in /in/c4UaD on line 11
Process exited with code 255.

preferences:
210.81 ms | 401 KiB | 293 Q