I have a problem with this code in Safari (in Firefox and Chrome it works)

When I load the page, in the file created rows are duplicated. If you reload the page without closing the browser tab the script works well.

I attach a video to better understand

$fileName = 'test.txt';
$d = date("d/m/Y - H:i:s");
echo $d . "<br>\n";
echo '------------------------------------------' . "<br>\n";

file_put_contents($fileName, $d . PHP_EOL, FILE_APPEND);

$lines = file($fileName);
foreach($lines as $lineNum => $line) {
    echo "Line #" . ++$lineNum . " : " . $line . "<br />\n";
}
有帮助吗?

解决方案

From Apple:

Engineering has determined that this issue behaves as intended based on the following:

This occurs because we preload Top Hits in the background when it appears likely that they'll be selected from the completion list. This behavior can be disabled from Safari's Privacy preference pane via the "Do not preload Top Hit in the background" checkbox.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top