网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 PHP使用适合阅读的格式显示文件大小方法
内容
    本文实例讲述了PHP使用适合阅读的格式显示文件大小的方法。分享给大家供大家参考。具体分析如下:
    文件大小显示,例如 1.7K , 2.9M
    代码如下:
    // A much better and accurate version can be found
    // in Aidan's PHP Repository:
    // http://aidanlister.com/repos/v/function.size_readable.php
    /**
    * Returns a human readable filesize
    *
    * @author wesman20 (php.net)
    * @author Jonas John
    * @version 0.3
    * @link http://www.jonasjohn.de/snippets/php/readable-filesize.htm
    */
    function HumanReadableFilesize($size) {
    // Adapted from: http://www.php.net/manual/en/function.filesize.php
    $mod = 1024;
    $units = explode(' ','B KB MB GB TB PB');
    for ($i = 0; $size > $mod; $i++) {
    $size /= $mod;
    }
    return round($size, 2) . ' ' . $units[$i];
    }
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/15 9:00:35