首頁  >  文章  >  後端開發  >  php如何获取文件大小_PHP教程

php如何获取文件大小_PHP教程

WBOY
WBOY原創
2016-07-13 10:36:32766瀏覽


代码:

<span static</span> <span function</span> convert(<span $size</span><span ) { 
</span><span $unit</span>=<span array</span>('b','kb','mb','gb','tb','pb'<span ); 
</span><span return</span> @<span round</span>(<span $size</span>/<span pow</span>(1024,(<span $i</span>=<span floor</span>(<span log</span>(<span $size</span>,1024)))),2).' '.<span $unit</span>[<span $i</span><span ]; 
}</span>

<span /*</span><span *
* Returns a human readable filesize
</span><span */</span> by www.jbxue.<span com
</span><span function</span> HumanReadableFilesize(<span $size</span><span ) {
</span><span $mod</span> = 1024<span ; 
</span><span $units</span> = <span explode</span>(' ','B KB MB GB TB PB'<span );
</span><span for</span> (<span $i</span> = 0; <span $size</span> > <span $mod</span>; <span $i</span>++<span ) {
</span><span $size</span> /= <span $mod</span><span ;
}
</span><span return</span> <span round</span>(<span $size</span>, 2) . ' ' . <span $units</span>[<span $i</span><span ];
}</span>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/738528.htmlTechArticle代码: convert( = ('b','kb','mb','gb','tb','pb' @ ( / (1024,( = ( ( ,1024)))),2).' '. [ by www.jbxue. HumanReadableFilesize( = 1024 = (' ','B KB MB GB TB PB' ( = 0; ; ++ /= ( , 2)...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn