/**
* 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 = "";
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 = "";
exit($str);
}
return $alert;
}
标签:string,success,url,param,alert,URL,跳转,msg,php
来源: https://www.cnblogs.com/shenchanglu/p/12197169.html