Recently I started using php v7.4 and got this error Trying to access array offset on value of type int
function getsize($size) {
if ($size === null) return null;
$last = strtolower($size{strlen($size)-1});
$size = (int) $size;
switch($last) {
case 'g':
$size *= 1024;
case 'm':
$size *= 1024;
case 'k':
$size *= 1024;
}
return $size;
}
how do I fix it :'(
no errors, just switched curly braces to brackets and it worked, (after setting $size = strlen($size); as Barno said)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.