PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

PHP 读取文件内容代码(txt,js等)_PHP教程

原创
2016-07-21 15:42:25 996浏览

/*
作者: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 :整行读取,遇到回车换行或结尾停止.在文本方式时使用.

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/320960.htmlTechArticle?php /* 作者:bjf; 应用:读取文件内容; */ function read_file_content($FileName) { //open file $fp=fopen($FileName,"r"); $data=""; while(!feof($fp)) { //read the file $da...
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。