3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(int $integer): int { return $integer; } try { var_dump(foo(1)); } catch (TypeError $e) { echo "Exception! "; var_dump($e); } try { var_dump(foo("1")); } catch (TypeError $e) { echo "Exception! "; var_dump($e); } try { var_dump(foo("a")); } catch (TypeError $e) { echo "Exception! "; var_dump($e); } try { var_dump(foo("0x0F")); } catch (TypeError $e) { echo "Exception! "; var_dump($e); } try { var_dump(foo(0x0F)); } catch (TypeError $e) { echo "Exception! "; var_dump($e); }
Output for git.master, git.master_jit, rfc.property-hooks
int(1) int(1) Exception! object(TypeError)#1 (7) { ["message":protected]=> string(95) "foo(): Argument #1 ($integer) must be of type int, string given, called in /in/H28Ge on line 20" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/H28Ge" ["line":protected]=> int(3) ["trace":"Error":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/H28Ge" ["line"]=> int(20) ["function"]=> string(3) "foo" ["args"]=> array(1) { [0]=> string(1) "a" } } } ["previous":"Error":private]=> NULL } Exception! object(TypeError)#2 (7) { ["message":protected]=> string(95) "foo(): Argument #1 ($integer) must be of type int, string given, called in /in/H28Ge on line 27" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/H28Ge" ["line":protected]=> int(3) ["trace":"Error":private]=> array(1) { [0]=> array(4) { ["file"]=> string(9) "/in/H28Ge" ["line"]=> int(27) ["function"]=> string(3) "foo" ["args"]=> array(1) { [0]=> string(4) "0x0F" } } } ["previous":"Error":private]=> NULL } int(15)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.59 ms | 404 KiB | 8 Q