PHP檔案系統常用函式解析

2021-07-15 11:41:09 字數 796 閱讀 3589

經常使用php一定離不開對檔案相關的操作,今天就大概總結一下這些常用的檔案系統函式。

讀取檔案相關函式

1.file_get_contents-------------

將整個檔案讀入乙個字串(與file()相似)。

2.file()------把整個檔案讀入到乙個陣列中。

3.readfile()-------讀取檔案並寫入到輸出緩衝區中。

4.fopen()------開啟檔案或者url,將filename指定的名字資源繫結到乙個流上。

5.fgets---從檔案指標中讀取一行。

string

fgets

( resource$handle[, 

int$length] )  $handle必須是fopen或fsockopen開啟的,並且未關閉。

6.fread()

----------從檔案指標handle讀取最多length個位元組

string

fread

( resource$handle

int$length)

6.fwrite()

----------把string的內容寫入 檔案指標handle處。  fputs是它的別名。

7.fclose

— 關閉乙個已開啟的檔案指標

PHP檔案系統操作常用函式

1 2 以文字形式返回檔案的型別 3 param type filename description 4 return type description 5 6function getfiletype filename 19 1 2 返回格式化後的檔案大小 3 param type size des...

PHP檔案系統

php具有豐富的檔案操作函式,最簡單的讀取檔案的函式為file get contents,可以將整個檔案全部讀取到乙個字串中。content file get contents test.txt file get contents也可以通過引數控制讀取內容的開始點以及長度。content file ...

PHP 檔案系統

file get contents 整個檔案全部讀取到乙個字串中 fopen 檔案路徑 模式 feof end of file fgets 讀取一行 fread source,num 一次讀取num個字串 fclose 避免檔案控制代碼被占用 對檔案進行操作前,先判斷檔案是否存在,用到的函式 is ...