
首先,打开php编辑器,新建php文件,例如:index.php。(推荐学习:PHP编程从入门到精通)
在index.php中,输入代码:echo ("<script>setTimeout('window.location.reload()', 1);</script>");。
浏览器运行index.php页面,此时发现页面会自动刷新。
代码:
<?php //echo "系统当前时间戳为:";echo "";echo time();echo "<br>";//<!--JS 页面自动刷新 -->echo ("<script type=\"text/javascript\">");echo ("function fresh_page()"); echo ("{");echo ("window.location.reload();");echo ("}"); echo ("setTimeout('fresh_page()',1000);"); echo ("</script>");?>
以上就是php如何自动刷新页面的知识。速戳>>知识兔学习精品课!