class MyCustomExceptionHandler extends Exception {
public function __construct($e) {
parent::__construct($e->getMessage());
$this->code = $e->getCode();
}
}
function get_config_bytes($val) {
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
$intval = intval(trim($val));
switch($last) {
case 'g':
$intval *= 1024;
case 'm':
$intval *= 1024;
case 'k':
$intval *= 1024;
}
return $this->fix_integer_overflow($intval);
}
函数 fix _ whole _ overflow
// Fix for overflowing signed 32 bit integers,
// works for sizes up to 2^32-1 bytes (4 GiB - 1):
protected function fix_integer_overflow($size) {
if ($size < 0) {
$size += 2.0 * (PHP_INT_MAX + 1);
}
return $size;
}