在PHP中如何在3秒内切换到另一个页面?
以下是我的尝试:在PHP中如何在3秒内切换到另一个页面?,php,refresh,Php,Refresh,以下是我的尝试: @header("Content-type: text/html; charset=utf-8"); @header("Location:/index.php"); @header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past 如您所见,“3秒钟”没有控制权,如何使其在
@header("Content-type: text/html; charset=utf-8");
@header("Location:/index.php");
@header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
如您所见,“3秒钟”没有控制权,如何使其在3秒钟内生效?最简单的方法是使用或javascript重定向。至于如何提供text/html,您可以将其中任何一个回送到浏览器
<meta http-equiv="refresh" content="3;URL=/newpage.php">
编辑:根据上的Wikipedia页面,您可以从PHP将刷新
标题直接发送到浏览器。不过,关于浏览器对这一点的支持程度,目前尚不清楚
header('Refresh: 3; url=/newpage.php');
实现这一点的最简单方法是使用或javascript重定向。至于如何提供text/html,您可以将其中任何一个回送到浏览器
<meta http-equiv="refresh" content="3;URL=/newpage.php">
编辑:根据上的Wikipedia页面,您可以从PHP将刷新
标题直接发送到浏览器。不过,关于浏览器对这一点的支持程度,目前尚不清楚
header('Refresh: 3; url=/newpage.php');
在PHP中,这应该是可行的:
header('Refresh: 3; url=index.php');
在PHP中,这应该是可行的:
header('Refresh: 3; url=index.php');
您可以利用refresh meta标记,如下所示:
<html>
<head>
<title>redirect page</title>
<META http-equiv="refresh" content="5;URL=http://www.newurl.com">
</head>
<body bgcolor="#ffffff">
The contents you are looking for have moved.
You will be redirected to the new location automatically in 5 seconds.
</body>
</html>
重定向页面
您要查找的内容已移动。
您将在5秒内自动重定向到新位置。
您可以利用刷新元标记,如下所示:
<html>
<head>
<title>redirect page</title>
<META http-equiv="refresh" content="5;URL=http://www.newurl.com">
</head>
<body bgcolor="#ffffff">
The contents you are looking for have moved.
You will be redirected to the new location automatically in 5 seconds.
</body>
</html>
重定向页面
您要查找的内容已移动。
您将在5秒内自动重定向到新位置。
我记得看到一个PHP函数可以同时输出这两个参数。我真的不需要去寻找它——Asker可以实现它。我记得看到一个PHP函数可以同时输出这两个。不需要去寻找它-询问者可以实现它。不同的浏览器如何支持它?AFAIK,所有主要的浏览器都支持它。请注意,此代码必须在页面上任何其他php代码之前出现。不同的浏览器如何支持它?AFAIK,所有主流浏览器都支持它。请注意,此代码必须位于页面上任何其他php代码之前。