php success error 封裝跳轉
/** * Warning提示信息 * @param string $type 提示類型 默認支持success, error, info * @param string $msg 提示信息 * @param string $url 跳轉的URL地址 * @param string $time 信息提示時間 * @return void */ function alert($type='info', $msg='', $url='', $time=1000) { //多行URL地址支持 $url = str_replace(array("\n", "\r"), '', $url); $alert = unserialize(stripslashes(cookie('alert'))); if (!empty($msg)) { $alert[$type][] = $msg; cookie('alert', serialize($alert)); } cookie('alerttime', $time); if (empty($url)) { $url = U('index/index'); //定義無URL時的跳轉地址 } if (!headers_sent()) { header('Location: ' . $url); exit(); } else { $str = "<meta http-equiv='Refresh' content='0;URL={$url}'>"; exit($str); } return $alert; }
/**
* Warning提示信息
* @param string $type 提示類型 默認支持success, error, info
* @param string $msg 提示信息
* @param string $url 跳轉的URL地址
* @param string $time 信息提示時間
* @return void
*/
function alert($type='info', $msg='', $url='', $time=1000) {
//多行URL地址支持
$url = str_replace(array("\n", "\r"), '', $url);
$alert = unserialize(stripslashes(cookie('alert')));
if (!empty($msg)) {
$alert[$type][] = $msg;
cookie('alert', serialize($alert));
}
cookie('alerttime', $time);
if (empty($url)) {
$url = U('index/index'); //定義無URL時的跳轉地址
}
if (!headers_sent()) {
header('Location: ' . $url);
exit();
} else {
$str = "<meta http-equiv='Refresh' content='0;URL={$url}'>";
exit($str);
}
return $alert;
}
浙公網安備 33010602011771號