3v4l.org

run code in 300+ PHP versions simultaneously
<?php function file_format_size($bytes, $decimals = 2) { $unit_list = array('B', 'KB', 'MB', 'GB', 'PB'); if ($bytes == 0) { return $bytes . ' ' . $unit_list[0]; } $unit_count = count($unit_list); for ($i = $unit_count - 1; $i >= 0; $i--) { $power = $i * 10; if (($bytes >> $power) >= 1) return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i]; } } foreach ([0, 10, 100, 1000, 1024, 10000, 100000, 1000000, 10000000] as $bytes) { var_export(file_format_size($bytes)); echo "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
'0 B' '10 B' '100 B' '1000 B' '1 KB' '9.77 KB' '97.66 KB' '976.56 KB' '9.54 MB'

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:
50.85 ms | 401 KiB | 8 Q