3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add(float $a, float $b): float { return $a + $b; } var_dump(add("1", "1")); // float(2) var_dump(add("1", "1foo")); // PHP Notice: A non well formed numeric value encountered // float(2) var_dump((float) "foo"); // float(0) var_dump(floatval("foo")); // float(0) try { var_dump(add("1", "foo")); } catch (Throwable $e) { var_dump($e); } // PHP Fatal error: Uncaught TypeError: Argument 2 passed to add() must be of the type float, string given
Output for git.master, git.master_jit, rfc.property-hooks
float(2) Fatal error: Uncaught TypeError: add(): Argument #2 ($b) must be of type float, string given, called in /in/0m9je on line 9 and defined in /in/0m9je:3 Stack trace: #0 /in/0m9je(9): add(1.0, '1foo') #1 {main} thrown in /in/0m9je on line 3
Process exited with code 255.

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:
69.86 ms | 405 KiB | 5 Q