如果设置了变量等,我有一个需要重定向页面的函数...
问题是,这个函数位于php页面的底部.
这意味着,我输出了很多信息,所以我得到一个标题警告.
"警告 - 已经发送的标题......"
发送标头后有没有办法重定向?
谢谢
Pis*_*3.0 13
有方法,但它们基本上是解决方法:
最简单的是meta http-equiv:
<meta http-equiv="Refresh" content="0;http://www.example.com/newlocation">
Run Code Online (Sandbox Code Playgroud)
<head>元素之外不会喜欢这个,并且会陷入怪癖模式或者,您可以尝试JavaScript重定向:
<script>
window.location = 'http://www.example.com/newlocation';
</script>
Run Code Online (Sandbox Code Playgroud)