久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      PHP filesize() 函數(shù)

      filesize

      作用:函數(shù)返回指定文件的大小

      語(yǔ)法

      filesize(filename)

      參數(shù)

      filename:必需。規(guī)定要檢查的文件。

      返回值

      返回文件大小的字節(jié)數(shù),如果出錯(cuò)返回 FALSE 并生成一條 E_WARNING 級(jí)的錯(cuò)誤。

      filesize 示例

      示例一

      <?php  // 輸出類(lèi)似:somefile.txt: 1024 bytes  $filename = 'somefile.txt'; echo $filename . ': ' . filesize($filename) . ' bytes';  ?>

      示例二

      <?php function human_filesize($bytes, $decimals = 2) {   $sz = 'BKMGTP';   $factor = floor((strlen($bytes) - 1) / 3);   return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor]; } ?>

      示例三

      <?php /** * Converts bytes into human readable file size. * * @param string $bytes * @return string human readable file size (2,87 Мб) * @author Mogilev Arseny */ function FileSizeConvert($bytes) {     $bytes = floatval($bytes);         $arBytes = array(             0 => array(                 "UNIT" => "TB",                 "VALUE" => pow(1024, 4)             ),             1 => array(                 "UNIT" => "GB",                 "VALUE" => pow(1024, 3)             ),             2 => array(                 "UNIT" => "MB",                 "VALUE" => pow(1024, 2)             ),             3 => array(                 "UNIT" => "KB",                 "VALUE" => 1024             ),             4 => array(                 "UNIT" => "B",                 "VALUE" => 1             ),         );      foreach($arBytes as $arItem)     {         if($bytes >= $arItem["VALUE"])         {             $result = $bytes / $arItem["VALUE"];             $result = str_replace(".", "," , strval(round($result, 2)))." ".$arItem["UNIT"];             break;         }     }     return $result; }  ?>

      示例四

      <?php /** * Return file size (even for file > 2 Gb) * For file size over PHP_INT_MAX (2 147 483 647), PHP filesize function loops from -PHP_INT_MAX to PHP_INT_MAX. * * @param string $path Path of the file * @return mixed File size or false if error */ function realFileSize($path) {     if (!file_exists($path))         return false;      $size = filesize($path);         if (!($file = fopen($path, 'rb')))         return false;         if ($size >= 0)     {//Check if it really is a small file (< 2 GB)         if (fseek($file, 0, SEEK_END) === 0)         {//It really is a small file             fclose($file);             return $size;         }     }         //Quickly jump the first 2 GB with fseek. After that fseek is not working on 32 bit php (it uses int internally)     $size = PHP_INT_MAX - 1;     if (fseek($file, PHP_INT_MAX - 1) !== 0)     {         fclose($file);         return false;     }         $length = 1024 * 1024;     while (!feof($file))     {//Read the file until end         $read = fread($file, $length);         $size = bcadd($size, $length);     }     $size = bcsub($size, $length);     $size = bcadd($size, strlen($read));         fclose($file);     return $size; }

      推薦教程:《PHP》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)