Home >Backend Development >PHP Tutorial >Capacity formatting function

Capacity formatting function

WBOY
WBOYOriginal
2016-07-25 09:10:53935browse
A very simple paragraph, nothing much to say..                                                                 
                                                                                                                                                                                                                                                                                                    



/**
* Capacity formatting
*
    * @param Int $filesize
  1. * @return Srting
  2. */
  3. function sizecount ($filesize)
  4. {
  5. if ($filesize >= 1073741824) $filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
  6. elseif ($filesize >= 1048576) $filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
  7. elseif ($filesize >= 1024) $filesize = round($filesize / 1024 * 100 ) / 100 . ' KB';
  8. else $filesize = $filesize . ' Bytes';
  9. return $filesize;
  10. }
  11. Copy code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:URI handler functionNext article:URI handler function