doumi5223 2014-05-01 06:00 采纳率: 100%
浏览 52
已采纳

Safari加载PHP脚本两次

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

  1. $fileName = 'test.txt';
  2. $d = date("d/m/Y - H:i:s");
  3. echo $d . "<br>
  4. ";
  5. echo '------------------------------------------' . "<br>
  6. ";
  7. file_put_contents($fileName, $d . PHP_EOL, FILE_APPEND);
  8. $lines = file($fileName);
  9. foreach($lines as $lineNum => $line) {
  10. echo "Line #" . ++$lineNum . " : " . $line . "<br />
  11. ";
  12. }
  • 写回答

1条回答 默认 最新

  • donglinxi1467 2014-05-01 06:08
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部