PHP 檔案程式設計

2022-09-09 17:45:24 字數 1606 閱讀 9398

建立資料夾

bool mkdir(url)

刪除資料夾

bool rmdir(url)

讀取目錄

opendir(url) 返回乙個路徑資源 //url不能是檔案

readdir()從資源中讀取(返回)乙個檔案(夾)名字後,指標後移

關閉目錄

closedir() 關閉資源

其他dirname(url) //url可以是檔案

返回上一級目錄

realpath(url) //url只能是目錄,如果是檔案返回false

返回乙個原路徑

is_dir(url)

scandir(url)

獲取指定路徑下的所有檔案資訊,已陣列形式返回

is_file(url)

dirname()

basename()

獲取檔名

file_get_contents(檔案路徑)

讀取檔案內容

file_put_coontents(檔案路徑,內容)

向指定的檔案寫入內容

fopen()

fread()

fwrite()

fclose()

filesize()

file_exists()

判斷檔案是否存在

unlink()

刪除檔案

filemtime()

獲取檔案最後一次了修改的時間

fseek()

設定fopen開啟檔案的指標位置

fgetc()

一次獲取乙個字元

header('location:'.$url); //location和":"之間無空格。
header('content-type:text/html;charset=utf-8');
header('http/1.1 404 not found');
header('refresh: 3; url=');  //3s後跳轉。
header('content-disposition: attachment; filename="example.zip"'); //設定mime使用者作為附件

header('content-transfer-encoding: binary'); //設定傳輸方式

header('content-length: '.filesize('example.zip')); //設定內容長度

function unloading($file)
function sfa($url=null)

}}else

}

PHP 檔案程式設計

1.6.1 資料夾操作 1 建立資料夾 mkdir 路徑,許可權,是否遞迴建立 make 建立 directory 目錄,資料夾例題 1 建立目錄 mkdir aa 建立aa資料夾 mkdir aa bb 在aa目錄下建立bb aa目錄必須存在 mkdir aa bb cc dd 0777 true...

php檔案程式設計

1.檔案的寫入寫出 2.檔案判斷與刪除 3.讀取二進位制檔案 description 檔案程式設計 0x01檔案的寫入寫出 檔案的寫入 file put contents string filename,mixed data int flags 0 resource context int file...

PHP學習筆記 PHP檔案程式設計

第122講 php檔案程式設計 檔案操作原理如何獲取檔案資訊,如何讀檔案 在web 在對檔案操作的過程中,我們是以流的概念來操作 如何獲取檔案資訊 開啟檔案 fopen 檔案路徑,開啟的模式 返回值是檔案指標 檢視檔案資訊 fstat 檔名 返回值是存放著陣列中 關閉檔案 fclose 開啟的檔案的...