php读取文件fopen(),feof(),fread(),fgets(),fclose()全套

来源:互联网 发布:淘宝退款金额不能修改 编辑:程序博客网 时间:2024/06/04 19:14
<?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 :整行读取,遇到回车换行或结尾停止,在文本text 时使用. 
0 0
原创粉丝点击