php fgets file_get_contents读取文件
发布时间:2020-05-25 22:10:12 所属栏目:PHP 来源:互联网
导读:本文章向码农们介绍php fgets file_get_contents读取文件的方法。区别在于fgets只能读取一行数据,file_get_contents直接将数据全部读
|
读取data文件里的数据 header("Content-type: text/html; charset=utf-8"); //read data $f = fopen('data','r'); $content = fgets($f); echo $content; fclose($f); 如果有多行数据该怎么读取? 方法一 while: header("Content-type: text/html; charset=utf-8"); $f = fopen('data','r'); //读取多行数据 while while(!feof($f)){//feof() 函数检测是否已到达文件末尾 $content = fgets($f); echo $content; } fclose($f); 方法二 file_get_contents(): echo file_get_contents('data'); (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
