3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bytes_to_int($size) { var_dump($size); // Remove the non-unit characters from the size. $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-numeric characters from the size. $size = preg_replace('/[^0-9\.]/', '', $size); if ($unit) { var_dump(round($size * pow(1024, stripos('bkmgtpezy', $unit[0])))); } else { var_dump(round($size)); } print "\n\n"; } bytes_to_int('12,2'); bytes_to_int('12,2 b'); bytes_to_int(''); bytes_to_int('m');
Output for git.master, git.master_jit, rfc.property-hooks
string(4) "12,2" float(122) string(6) "12,2 b" float(122) string(0) "" Fatal error: Uncaught TypeError: round(): Argument #1 ($num) must be of type int|float, string given in /in/OUJaH:14 Stack trace: #0 /in/OUJaH(14): round('') #1 /in/OUJaH(21): bytes_to_int('') #2 {main} thrown in /in/OUJaH 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:
37.38 ms | 406 KiB | 5 Q