|
/*
作者:bjf;
應用:讀取文件內(nèi)容;
*/
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的區(qū)別
fread :以字節(jié)位計算長度,按照指定的長度和次數(shù)讀取數(shù)據(jù),遇到結(jié)尾或完成指定長度讀取后停止.
fgets :整行讀取,遇到回車換行或結(jié)尾停止.在文本方式時使用.
php技術:PHP 讀取文件內(nèi)容代碼(txt,js等),轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。