php获取文件内容最后一行示例


$rs = 'README.md';
$fp = fopen($rs, 'r');

fseek($fp,-1,SEEK_END);

$s = '';
while(($c = fgetc($fp)) !== false)
{
  if($c == "\n" && $s) break;
  $s = $c . $s;
  fseek($fp, -2, SEEK_CUR);
}
fclose($fp);
echo $s;
exit;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/f4573bfcb9efc510ef18ebc28ae495ec.html