PHP資料夾操作2

2022-08-14 08:39:10 字數 922 閱讀 2899

mkdir("路徑檔名");    建立資料夾

imdir("路徑檔名"); 刪除資料夾(只能刪除空的資料夾)

rename("路徑","新路徑"); 移動資料夾(可以修改名字)

檔案操作:

touch("路徑"); 建立檔案

copy("檔案路徑","新檔案路徑"); 複製檔案

unlink("檔案路徑"); 刪除檔案

file_get_contents("檔案路徑"); 獲取檔案內容(本地內容、遠端內容都可以獲取)

file_put_contents("檔案路徑"."內容"); 寫入內容

raedfile("檔名"); 讀取問件內容並輸出

$f = fopen("./11.txt","r");     //

開啟檔案並返回檔案資源

fwrite($f,"hello world"); //

寫入內容

echo

fgetc($f); //

讀取檔案內容,乙個字元乙個字元的讀

echo

fgets($f); //

讀取檔案內容,每次讀一行

echo

fread($f,10); //

讀取檔案內容,按照長度來讀

fclose($f); //

關閉檔案資源

刪除檔案

function shanchu($fname

)

else}}

closedir($dir

);

//刪除資料夾

rmdir($fname);}

shanchu("./0904");

php資料夾操作

本文講述了使用php如何操作資料夾,主要是一些函式的使用,非常基礎。0x01 建立資料夾 mkdir 0x02 刪除資料夾 rmdir 0x03 重新命名資料夾 rename 0x04 判斷是否是資料夾 is dir 0x05 開啟 讀取 關閉資料夾 opendir readdir closedir...

php操作資料夾

對檔案內容操作 readfile a.txt 讀取文字內容 var dump file a.txt 索引陣列對每一行排序 str file get contents a.txt 把檔案內容原樣輸出相當於python的 var dump str file put contents tst.txt 這是...

php資料夾的相關操作

php獲取資料夾大小 function dirsize path if is dir path.item closedir handle return sum 注意用的時候記得每次 要清0,要不然會累加 php建立資料夾 建立資料夾 param string dirname return strin...