php 存储容量换算

function setupSize($fileSize) {     
    $size = sprintf("%u", $fileSize);     
    if($size == 0) {          
        return("0 Bytes");     
    }    
    $sizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");     
    return round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizename[$i]; 
}

你可能感兴趣的:(php)