function createFileTail(string $path){
$server = $_SERVER['DOCUMENT_ROOT'];
$targetFilePath = ($server . $path);
$targetFileTime = filemtime($targetFilePath);
$saveFilePath = ($server . "tailHistory.json");
$saveFileTime = 0;
$history = json_decode(
file_get_contents($saveFilePath), true
);
if(!array_key_exists($path, $history) || $history[$path] < $targetFileTime){
$saveFileTime = $targetFileTime;
$history[$path] = $saveFileTime;
file_put_contents(
$saveFilePath, json_encode($history)
);
}else{
$saveFileTime = $history[$path];
}
return $saveFileTime;
}
src="/client.js?<?=createFileTail('client.js')?>"