日期:2014-05-17  浏览次数:20497 次

php读取linux文件
请大家帮忙写一个php读取linux文件内容并显示的例子,如我的文件linux绝对路径 /etc/a/b/c.conf,我把文件权限改成了777
我这样写的:
<?
  $testfile="/etc/a/b/c.conf";
  $fp=fopen($testfile,'r+');
  $outputtext=fgets($testfile,filesize($testfile));
  echo "$testfile文本内容:".$outputtext;
  fclose($fp)
?>

但是没有输出内容,请大家看下是什么问题?是文件路径的写法有问题还是什么其他原因?

------解决方案--------------------
file_get_contents() 试试这个