日期:2014-05-16 浏览次数:20470 次
<?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"); ?>