|
/*
作者:bjf;
應用:讀取文件內容;
*/
function read_file_content($FileName)
{
//open file
$fp=fopen($FileName,"r");
$data="";
while(!feof($fp))
{
//read the file
$data.=fread($fp,4096);
}
//close the file
fclose($fp);
//delete the file
//unlink($FileName);
//return the content from the file
echo $data;
}
read_file_content("a.html")
?>
fread與fgets的區別
fread :以字節位計算長度,按照指定的長度和次數讀取數據,遇到結尾或完成指定長度讀取后停止.
fgets :整行讀取,遇到回車換行或結尾停止.在文本方式時使用.
php技術:PHP 讀取文件內容代碼(txt,js等),轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。