标题刷新

5 php header

if (strlen($_POST['reply']) < 6) {
header("Refresh: 2; url=thread.php?id=$tid#reply");
die("The text you have entered is too short. Please write a longer text and try again.");
}
Run Code Online (Sandbox Code Playgroud)

添加#reply时,为什么标题刷新不起作用?给出一个空白页面.它适用于标题位置.任何的想法?

dus*_*oft 6

哈希符号(#)之后的任何内容都是URL的本地部分,不应强制刷新.此外,如果您在浏览器的URL中有#reply并在地址栏中再次按Enter键,则页面不会刷新,您只是被带到页面的#reply部分(目标).

另请注意,您通过不使用完整URL来破坏标准.你应该使用:url = http://server.com/thread.php?id= $ tid#reply

PS:我建议使用Header("Location: xxxxxxxx"); 你应该在META标签中放置刷新