fgets函数逐行读取文件内容
<?php
header("Content-type:text/html;charset=utf-8");
//打开文件,否则就提示打开错误
$file=fopen("welcome.txt","r") or die("Unable to open file!");
while(!feof($file)){ //非结尾就执行下面语句
echo fgets($file,1024); //逐行执行文件内容
}
fclose($file); //关闭文件
?>
feof检测是否是末尾
fgetc单个字符读取文件内容
fgets是逐行读取文件内容
header("Content-type:text/html;charset=utf-8");
//打开文件,否则就提示打开错误
$file=fopen("welcome.txt","r") or die("Unable to open file!");
while(!feof($file)){ //非结尾就执行下面语句
echo fgets($file,1024); //逐行执行文件内容
}
fclose($file); //关闭文件
?>
feof检测是否是末尾
fgetc单个字符读取文件内容
fgets是逐行读取文件内容