<?php/** * Created by PhpStorm. * User: FelayMan * Date: 14-4-7 * Time: 下午6:14 */ header("content-type:text/html;charset=utf-8"); //第一种方式获取文件内容 function getallcontent1($filename){ //file — 把整个文件读入一个数组中 $content = file_get_contents($filename); return $content; } //第二种方式获取文件内容 function getallcontent2($filename){ $arr = file($filename); $content=''; foreach($arr as $value){ $content.=$value; } $content.=iconv("gbk","utf-8",$content); return $content; } //第三种方式获取文件内容 function getallcontent3($filename){ readfile($filename); } //$content = getallcontent1("index.txt"); //$content = getallcontent2("index.txt"); // echo $content; getallcontent3("index.txt");?>
详细解决方案
felayman-php_读取文件内容的三种步骤
热度:343 发布时间:2016-04-28 19:27:20.0