3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getValueInBytes($input) { // see: http://www.php.net/manual/en/function.ini-get.php $input = trim($input); $last = strtolower($input[strlen($input) - 1]); $numericInput = (float) substr($input, 0, -1); switch ($last) { case 'g': $numericInput *= 1024; case 'm': $numericInput *= 1024; case 'k': $numericInput *= 1024; return $numericInput; } return $input; } echo getValueInBytes(-1);
Output for 5.6.30 - 5.6.38, hhvm-3.18.5 - 3.22.0, 7.0.28 - 7.3.0rc3
-1