欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-04-16 15:02:19
...
复制代码 代码如下:

$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;

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/676863.htmlTechArticle复制代码 代码如下: $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; fs...