PHP打开并显示文件内容

版权声明:转载请注明出处http://blog.csdn.net/xuaho0907 https://blog.csdn.net/xuaho0907/article/details/82531274

<?php
$file_handle = fopen("/data/webroot/resource/php/f.txt","r");    //返回值是资源类型。
if ($file_handle){
    //接着采用while循环一行行地读取文件,然后输出每行的文字
    while (!feof($file_handle)) { //如果不是最后一行就一直循环执行
        $line = fgets($file_handle); //读取一行文本
        echo $line; //输出一行文本
        echo "<br />"; //换行
    }
}
fclose($file_handle);//关闭文件,释放资源
?>

猜你喜欢

转载自blog.csdn.net/xuaho0907/article/details/82531274