给我一下discuz的自动跳转函数
时间: 2023-12-25 16:04:22 浏览: 31
以下是Discuz的自动跳转函数:
```php
/**
* 自动跳转函数
*
* @param string $url 跳转的URL地址
* @param int $time 等待时间(单位:秒)
* @param string $msg 跳转提示信息
*/
function dheader($url, $time = 0, $msg = '') {
// 防止重复跳转
if (empty($url)) {
return false;
}
if (!empty($msg)) {
$msg = "<script>alert('$msg');</script>";
}
if (!empty($time)) {
$time = "setTimeout(\"window.location.href='$url'\", " . ($time * 1000) . ");";
}
header("Content-type: text/html; charset=utf-8");
header("Cache-control: private");
echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'><meta http-equiv='Cache-Control' content='no-cache'><title>跳转提示</title></head><body>$msg<div style='text-align:center;font-size:14px;margin-top:10px;'>$url</div><script>$time</script></body></html>";
exit();
}
```
使用方法:
```php
// 跳转到百度首页,等待 3 秒,显示“正在跳转到百度...”的提示信息
dheader('http://www.baidu.com', 3, '正在跳转到百度...');
```
相关推荐
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)