十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
/**
在九江等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都做網(wǎng)站、成都網(wǎng)站制作 網(wǎng)站設計制作定制網(wǎng)站,公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,成都品牌網(wǎng)站建設,網(wǎng)絡營銷推廣,成都外貿(mào)網(wǎng)站建設,九江網(wǎng)站建設費用合理。
* 返回格式化的文件大小
* @param string $byte
* @return string
*/
function transBytes($byte){
$arrar=array("B","KB","MB","GB","TB","PB");
$i=0;
while(($byte/1024)>1){
$byte=$byte/1024;
$i++;
}
return round($byte,2).$arrar[$i];
}
/**
* 遞歸獲取指定目錄下的所有文件(對比下面的讀取目錄函數(shù))
* @param string $path
* @return 2維 array
*/
function getAllFiles($path){
if(file_exists($path)){
//global $array;
static $array=array();
$handle=opendir($path);
while(($item=readdir($handle))!==false){
if($item!="."&&$item!=".."){
if(is_file($path."/".$item)){
//echo $item;
$array['file'][]=$item;
}
if(is_dir($path."/".$item)){
$array['dir'][]=$item;
$func=__FUNCTION__;
$func($path."/".$item);
}
}
}
closedir($handle);
return $array;
}
}
//print_r(getAllFiles("../function"));
/**
* 讀取指定目錄下的文件和文件夾,不遞歸查詢子文件夾
* @param string $path
* @return 2維 array
*/
function readDirectory($path){
if(file_exists($path)){
if(is_dir($path)){
//static $arrar=array();不需要顯示子文件夾內(nèi)容
$handle=opendir($path);
while(($item=readdir($handle))!==false){
if($item!="."&&$item!=".."){
if(is_file($path."/".$item)){
$array['file'][]=$item;
}
if(is_dir($path."/".$item)){
$array['dir'][]=$item;
$func=__FUNCTION__;
$func($path."/".$item);
}
}
}
closedir($handle);
return $array;
}
}
else {
echo "目錄不存在!";
}
}
//print_r(readDirectory("../function"));
/**
* 獲得指定目錄的大小
* @param string $path
* @return number
*/
function getDirSize($path){
if(file_exists($path)){
if(is_dir($path)){
$handle=opendir($path);
static $sum=0;
while(($item=readdir($handle))!==false){
if($item!="."&&$item!=".."){
if(is_file($path."/".$item)){
$sum+=filesize($path."/".$item);
}
if(is_dir($path."/".$item)){
$func=__FUNCTION__;
$func($path."/".$item);
}
}
}
closedir($handle);
return $sum;
}else {
echo "這不是一個有效的目錄!";
}
}else{
echo "目錄不存在??!";
}
}
//echo transBytes(getDirSize("../js"));
/**
* 創(chuàng)建多級目錄
* @param string $path
* @param string $mode
* @param string $bool
*/
function createMultiDir($path,$mode="0777",$bool="TRUE"){
mkdir($path,$mode,$bool);
}
//var_dump(createMultiDir("3211"));
function alertMes($mes,$path){
echo "";
}
//alertMes("sorry", "explorer1.php");