【phpstudy】php 读取文件内容并一行行输出

时间:2016-11-06  来源:客户端相关打印  阅读:

php教程
// 打开文件同时打印文件的每一个字符
if($myfile = fopen("data.txt", "r"))
{
while(!feof($myfile))
{
$mycharacter = fgetc($myfile);//从文件指针中读取字符
print($mycharacter);
}
fclose($myfile);
}
// 打开文件同时打印文件的每一行
if($myfile = fopen("data.txt", "r"))
{
while(!feof($myfile))
{
$myline = fgets($myfile, 255);//从文件指针中读取一行
print($myline);
}
fclose($myfile);
}
/* 打开文件同时打印文件的每一行,
同时去掉取回字符串中的 html 语言
*/
if($myfile = fopen("data.txt", "r"))
{
while(!feof($myfile))
{
$myline = fgetss($myfile, 255);//从文件指针中读取一行并过滤掉 html 标记
print($myline);
}
fclose($myfile);
}
?>

【phpstudy】php 读取文件内容并一行行输出

http://m.bbyears.com/aspjiaocheng/28085.html

推荐访问:phpstorm php面试题 php数组转字符串 php教程
相关阅读 猜你喜欢
本类排行 本类最新