/**
* @method URL重定向
* @param string $url URL地址
* @param integer $time 等待时间(秒)
* @param string $msg 提示信息(将输出在网页端)
* @return void
*/
function redirect($url, $time = 0, $msg = '')
{
//多行URL地址支持
$url = str_replace(array("\n", "\r"), '', $url);
if (empty($msg))
$msg = "系统将在{$time}秒之后自动跳转到{$url}!";
if (!headers_sent()) {
// 执行重定向
if (0 === $time) {
header('Location: ' . $url);
} else {
header("refresh:{$time};url={$url}");
echo($msg);
}
exit();
} else {
$str = "<meta http-equiv='Refresh' content='{$time};URL={$url}'>";
if ($time != 0) {
$str .= $msg;
}
exit($str);
}
}
Last modification:March 18th, 2019 at 01:17 pm
© The copyright belongs to the author