最简单的天真解决方案是:
$file = "/path/to/file";$data = file($file);$line = $data[count($data)-1];
不过,这会将整个文件加载到内存中。可能是一个问题(或没有)。更好的解决方案是:
$file = escapeshellarg($file); // for the security concious (should be everyone!)$line = `tail -n 1 $file`;

最简单的天真解决方案是:
$file = "/path/to/file";$data = file($file);$line = $data[count($data)-1];
不过,这会将整个文件加载到内存中。可能是一个问题(或没有)。更好的解决方案是:
$file = escapeshellarg($file); // for the security concious (should be everyone!)$line = `tail -n 1 $file`;