====== Simuler tail en PHP ======
{{ :dummy.png?75x75|Simuler tail en PHP}}
{{tag>php}}
&1", 'r');
while(!feof($handle)) {
$buffer = fgets($handle);
echo "$buffer
\n";
ob_flush();
flush();
}
pclose($handle);
function follow($file)
{
$size = 0;
while (true) {
clearstatcache();
$currentSize = filesize($file);
if ($size == $currentSize) {
usleep(100);
continue;
}
$fh = fopen($file, "r");
fseek($fh, $size);
while ($d = fgets($fh)) {
echo $d;
}
fclose($fh);
$size = $currentSize;
}
}
follow("file.txt");