3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * convertBytes * * Convert bytes into human readable form with rounding * * @name convertBytes * @access public * @param integer $bytes * @param integer $decimals = 2 * @desc Convert bytes into human readable form with rounding * @return string */ function convertBytes($bytes, $decimals = 2) { $suffixes = 'BKMGTP'; $factor = floor((strlen($bytes) - 1) / 3); return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$suffixes[$factor]; } echo convertBytes(1500)."\n"; echo convertBytes(1500*1000)."\n"; echo convertBytes(1500*1000*1000)."\n"; echo convertBytes(1500*1000*1000*1000)."\n"; echo convertBytes(1500*1000*1000*1000*1000)."\n";
Output for git.master, git.master_jit, rfc.property-hooks
1.46K 1.43M 1.40G 1.36T 1.33P

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