可以使用 PHP 的 header 函数实现刷新并返回指定网页,示例代码如下:

// 刷新并返回指定网页
header('refresh:3;url=http://www.example.com');
echo '正在跳转到<a href='http://www.example.com'>http://www.example.com</a>,请稍等...';
?>

其中,header 函数的第一个参数为刷新指令,refresh 后面的数字表示刷新的时间(单位为秒),第二个参数为要返回的网页地址。在本例中,页面将在 3 秒后自动跳转到 http://www.example.com,并显示 '正在跳转到 http://www.example.com,请稍等...' 的提示信息。

注意:header 函数必须在页面输出之前调用,否则会出现 'headers already sent' 的错误。


原文地址: https://www.cveoy.top/t/topic/mlQe 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录