1 /** 2 * URL重定向 3 * @param string $url 重定向的URL地址 4 * @param integer $time 重定向的等待时间(秒) 5 * @param string $msg 重定向前的提示信息 6 * @return void 7 */ 8 function redirect($url, $time=0, $msg='') { 9 //多行URL地址支持10 $url = str_replace(array("\n", "\r"), '', $url);11 if (empty($msg))12 $msg = "系统将在{ $time}秒之后自动跳转到{ $url}!";13 if (!headers_sent()) {14 // redirect15 if (0 === $time) {16 header('Location: ' . $url);17 } else {18 header("refresh:{ $time};url={ $url}");19 echo($msg);20 }21 exit();22 } else {23 $str = " ";24 if ($time != 0)25 $str .= $msg;26 exit($str);27 }28 }