This article mainly introduces the method of php to obtain the file size. Friends who need it can refer to it
/** * Returns a human readable filesize */ function HumanReadableFilesize($size) { $mod = 1024; $units = explode(' ','B KB MB GB TB PB'); for ($i = 0; $size > $mod; $i++) { $size /= $mod; } return round($size, 2) . ' ' . $units[$i]; }
The above is the detailed content of PHP method example code to obtain file size. For more information, please follow other related articles on the PHP Chinese website!