3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = array( 20/3, 20/3 * 1e6, 6.66, 6.0, 60.0, 10/9, 1e20, ); $p = (int) ini_get('precision'); foreach ($numbers as $n) { echo 'RAW: ' . $n . "\n"; echo 'EXP: ' . var_export($n, TRUE) . "\n"; echo 'FIX: ' . rtrim(rtrim(sprintf('%.' . max($p - ceil(log10($n)), 0) . 'F', $n), '0'), '.') . "\n"; var_dump($n); echo "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
RAW: 6.6666666666667 EXP: 6.666666666666667 FIX: 6.6666666666667 float(6.666666666666667) RAW: 6666666.6666667 EXP: 6666666.666666667 FIX: 6666666.6666667 float(6666666.666666667) RAW: 6.66 EXP: 6.66 FIX: 6.66 float(6.66) RAW: 6 EXP: 6.0 FIX: 6 float(6) RAW: 60 EXP: 60.0 FIX: 60 float(60) RAW: 1.1111111111111 EXP: 1.1111111111111112 FIX: 1.1111111111111 float(1.1111111111111112) RAW: 1.0E+20 EXP: 1.0E+20 FIX: 1 float(1.0E+20)

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.6 ms | 402 KiB | 8 Q