On Wed, 15 Dec 2004, Nuno Lopes wrote:

> nlopess               Wed Dec 15 15:20:28 2004 EDT
>
>   Modified files:
>     /phpdoc/en/reference/info/functions       ini-get.xml
>   Log:
>   add the G ini modifier
>
> http://cvs.php.net/diff.php/phpdoc/en/reference/info/functions/ini-get.xml?r1=1.11&r2=1.12&ty=u
> Index: phpdoc/en/reference/info/functions/ini-get.xml
> diff -u phpdoc/en/reference/info/functions/ini-get.xml:1.11 
> phpdoc/en/reference/info/functions/ini-get.xml:1.12
> --- phpdoc/en/reference/info/functions/ini-get.xml:1.11       Thu Aug 12 
> 21:00:46 2004
> +++ phpdoc/en/reference/info/functions/ini-get.xml    Wed Dec 15 15:20:28 2004
> @@ -1,5 +1,5 @@
>  <?xml version="1.0" encoding="iso-8859-1"?>
> -<!-- $Revision: 1.11 $ -->
> +<!-- $Revision: 1.12 $ -->
>  <!-- splitted from ./en/functions/info.xml, last change in rev 1.64 -->
>    <refentry id="function.ini-get">
>     <refnamediv>
> @@ -60,16 +60,18 @@
>
>  function return_bytes($val) {
>      $val = trim($val);
> -    $last = $val{strlen($val)-1};
> +    $last = strtolower($val{strlen($val)-1});
>      switch($last) {
>          case 'k':
> -        case 'K':
>              return (int) $val * 1024;
>              break;
>          case 'm':
> -        case 'M':
>              return (int) $val * 1048576;
>              break;
> +        // The 'G' modifier is available since PHP 5.1.0
> +        case 'g':
> +            return (int) $val * 1073741824;
> +            break;
>          default:

Why not do it like:

switch($last) {
        case 'g':
                $val *= 1024;
        case 'm':
                $val *= 1024;
        case 'k':
                $val *= 1024;
}

is much shorter and cleaner looking.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

Reply via email to