<?php
/*
作者: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 :整行讀取,遇到回車換行或結尾停止.在文本方式時使用.