3v4l.org

run code in 300+ PHP versions simultaneously
<?php $d = distance([2,4], [26,9]); echo 'distance is : ' .$d; function distance( $p1=array(), $p2=array()) { $x1 = $p1[0]; $x2 = $p2[0]; $y1 = $p1[1]; $y2 = $p2[1]; echo "y1 is : $y1\n"; echo "y2 is : $y2\n"; echo "x1 is : $x1\n"; echo "x2 is : $x2\n"; /** $p1 = ($x1 - $x2); // $p2 = ($y1 - $y2); // $points = [$p1, $p2]; //$distance = array_sum($points); // $distance = sqrt(($x1 - $x2) + ($y1 - $y2))**2; */ $distance = hypot($p1, $p2); return $distance; }
Output for git.master, git.master_jit, rfc.property-hooks
y1 is : 4 y2 is : 9 x1 is : 2 x2 is : 26 Fatal error: Uncaught TypeError: hypot(): Argument #1 ($x) must be of type float, array given in /in/NUjFV:32 Stack trace: #0 /in/NUjFV(32): hypot(Array, Array) #1 /in/NUjFV(3): distance(Array, Array) #2 {main} thrown in /in/NUjFV on line 32
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:
58.33 ms | 401 KiB | 8 Q