PHP 中跳转到另一个页面
我很想知道除了使用 javascript 之外是否还有其他方法使 php 转到另一个页面?
因为 head 仅在第一个被调用的函数时才起作用,所以我求助于 javascript 来转到另一个页面。但是php一定有类似的功能不是吗?
<?php session_start();
session_destroy();
echo '<script language="JavaScript">
<!--
window.location="home.php";
//-->
</script>';
?>
I was curious to know if there was another way than using javascript to make php go to another page ?
Because head only works when it is the first function to be called, so I resorted to javascript to go to another page. But php must have a similar function no ?
<?php session_start();
session_destroy();
echo '<script language="JavaScript">
<!--
window.location="home.php";
//-->
</script>';
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你有一个错误。
需要是第一个输出的东西,这意味着,如果您回显在此之前的任何内容,它将不起作用,否则它将起作用。
所以只是:
You have a mistake.
Needs to be the first things that's being output, meaning, if you echo anything before this, it wont work, other wise it will work.
So just:
尝试
了解更多信息:php 手动标头函数
Cleber。
Try
For more info: php manual header function
Cleber.
您需要使用 php
http://www 中的函数标头修改 HTTP 响应的标头.php.net/manual/function.header.php
您还可以添加浏览器使用的特定标头。
例如,如果您的页面已永久移动,您可以使用:
您可以在以下位置查看有关重定向的更多信息: http:// /en.wikipedia.org/wiki/URL_redirection
You need to modify the header of your HTTP Response with the function header in php
http://www.php.net/manual/function.header.php
Also you can add a particular header used by the browser.
for example if your page has moved permanently, you can use:
You can see more information about redirection on: http://en.wikipedia.org/wiki/URL_redirection
当然。您可以使用“元重定向”:
http://webdesign.about.com/ od/metataglibraries/a/aa080300a.htm
例如:
<代码>
Sure. You can use a "meta redirect":
http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm
For example: