3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "start\n"; register_shutdown_function(function() { $err = error_get_last(); if ($err) { echo "Yes error_get_last\n"; echo "Error is: ".print_r($err, True); } else { echo "No error_get_last\n"; } echo "shutdown\n"; }); set_exception_handler(function($ex) { if ($ex instanceof Error) { echo "Exception Handler is Error\n"; return Null; } echo "Exception Handler\n"; die(); }); set_error_handler(function($errno, $errstr, $errfile, $errline, $errcontext) { echo "Error Handler: ".$errstr."\n"; echo "Error Type: ".$errno."\n"; die(); #throw new ErrorException("raising errorexception", 0, $errno, $errfile, $errline); }); class Foo { public function __construct($ii) { $this->internal = $ii; } public function foo1() { if ($this->internal === 5) { echo "Called Foo->foo1()\n"; } } public function other() { echo "Called Foo->other()\n"; } public function bad() { $doesnotexist->alsodoesnotexist(); } } $exists = new Foo(5); #$exists->foo1(); #$exists->doesnotexist(); #doesnotexist(); #$doesnotexist->alsodoesnotexist(); #ditto $exists->bad(); Foo::foo1(); #Foo::other(); #$x = $y + 5; #$file=fopen("welcome.txt","r"); #echo $foo . "appending<br />"; #$t = I_AM_NOT_DEFINED; # #trigger_error("Triggered Error", E_USER_ERROR); #password_hash("swordfish", PASSWORD_BCRYPT, array("salt"=>"sjienvidndiwnsosvknsfoiwnlnvsoi")); echo "Continuing execution\n";
Output for 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
start Exception Handler is Error No error_get_last shutdown
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 start Exception Handler is Error No error_get_last shutdown
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
start Error Handler: Non-static method Foo::foo1() should not be called statically Error Type: 8192 No error_get_last shutdown
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
start Error Handler: Non-static method Foo::foo1() should not be called statically Error Type: 2048 No error_get_last shutdown

preferences:
271.81 ms | 402 KiB | 330 Q