Skip to content

Commit 9ad2b94

Browse files
committed
对跳转的类使用结束检测,默认结束
1 parent 2300845 commit 9ad2b94

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

helper/system.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ function get_file_url($param = ''){
5858
* @param string|array $uri
5959
* @param string $method
6060
* @param int $http_response_code
61+
* @param bool $exit 是否退出,默认结束程序执行
6162
*/
62-
function redirect($uri = '', $method = 'refresh', $http_response_code = 302){
63-
if(is_array($uri) || !preg_match('#^https?://#i', $uri)){
63+
function redirect($uri = '', $method = 'refresh', $http_response_code = 302, $exit = true){
64+
if(is_array($uri) || !filter_var($uri, FILTER_VALIDATE_URL)){
6465
$uri = get_url($uri);
6566
}
6667
switch($method){
@@ -71,7 +72,9 @@ function redirect($uri = '', $method = 'refresh', $http_response_code = 302){
7172
header("Location: " . $uri, true, $http_response_code);
7273
break;
7374
}
74-
exit;
75+
if($exit){
76+
exit;
77+
}
7578
}
7679

7780
/**

0 commit comments

Comments
 (0)