3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo whole_fraction(23.54); function whole_fraction($decimal){ $big_fraction = float2rat($decimal); $num_array = explode('/', $big_fraction); echo $big_fraction; $numerator = $num_array[0]; $denomenator = $num_array[1]; echo $numerator; echo $denomenator; $whole_number = floor( $numerator / $denominator ); $numerator = $numerator % $denomenator; $fraction = $whole_number . ' ' . $numerator . '/' . $denomenator; } function float2rat($n, $tolerance = 1.e-6) { $h1=1; $h2=0; $k1=0; $k2=1; $b = 1/$n; do { $b = 1/$b; $a = floor($b); $aux = $h1; $h1 = $a*$h1+$h2; $h2 = $aux; $aux = $k1; $k1 = $a*$k1+$k2; $k2 = $aux; $b = $b-$a; } while (abs($n-$h1/$k1) > $n*$tolerance); return "$h1/$k1"; }
Output for git.master, git.master_jit, rfc.property-hooks
1177/50117750 Warning: Undefined variable $denominator in /in/3k2ZD on line 14 Fatal error: Uncaught DivisionByZeroError: Division by zero in /in/3k2ZD:14 Stack trace: #0 /in/3k2ZD(2): whole_fraction(23.54) #1 {main} thrown in /in/3k2ZD on line 14
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:
49.25 ms | 401 KiB | 8 Q