PHP 读取文件内容代码(txt,js等)
2009-12-06 00:00
911 查看
<?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 :整行读取,遇到回车换行或结尾停止.在文本方式时使用.
/*
作者: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 读取文件内容代码(txt,js等)
- PHP读取txt文件的内容并赋值给数组的代码
- PHP读取txt文件的内容并赋值给数组的代码
- PHP读取txt文件的内容并赋值给数组的代码
- js创建并读取txt文件的内容
- PHP读取文件内容后清空文件示例代码
- Node.js中读取TXT文件内容fs.readFile()用法
- php逐行读取.txt文件内容,并解析每行内容
- Node.js 读取TXT文件内容 fs.readFile()
- php 读取txt文件中的内容,转换成数组
- PHP 读取大文件的X行到Y行内容的实现代码
- php读取外部txt文件内容并打印在页面|fopen()函数
- PHP读取文件内容后清空文件的代码
- PHP读取TXT文件内容
- node.js实现逐行读取文件内容的代码
- PHP读取网页文件内容的实现代码(fopen,curl等)
- PHP读取txt文件 4000 的内容并赋值给数组…