• Resolved Art Smith

    (@ambrosiawt)


    In the function sb_return_kbytes, PHP now issues a notice (which my site kindly displays on the public side of the site) indicating that at line 267 (when the case is “m”) the computation is working with non-numeric data. Indeed, the “M” or “G” are still embedded in the $val variable. The following code corrects the issue:

    function sb_return_kbytes($val) {
            $val = trim($val);
            $last = strtolower($val[strlen($val)-1]);
            $val = preg_replace("/[^0-9.]/", "", $val);  // <- add this line
            switch($last) {
                    case 'g':
                            $val *= 1024;
                    case 'm':
                            $val *= 1024;
            }
       return intval($val);
    }

    Art Smith

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘function sb_return_kbytes error on PHP 7’ is closed to new replies.