君山 发表于 2020-9-29 11:11:57

Dizcuz dheader 函数 header 函数的兼容版



function dheader($string, $replace = true, $http_response_code = 0) {
        $islocation = substr(strtolower(trim($string)), 0, 8) == 'location';
        if(defined('IN_MOBILE') && strpos($string, 'mobile') === false && $islocation) {
                if (strpos($string, '?') === false) {
                        $string = $string.'?mobile='.IN_MOBILE;
                } else {
                        if(strpos($string, '#') === false) {
                                $string = $string.'&mobile='.IN_MOBILE;
                        } else {
                                $str_arr = explode('#', $string);
                                $str_arr = $str_arr.'&mobile='.IN_MOBILE;
                                $string = implode('#', $str_arr);
                        }
                }
        }
        $string = str_replace(array("\r", "\n"), array('', ''), $string);
        if(empty($http_response_code) || PHP_VERSION < '4.3' ) {
                @header($string, $replace);
        } else {
                @header($string, $replace, $http_response_code);
        }
        if($islocation) {
                exit();
        }
}
页: [1]
查看完整版本: Dizcuz dheader 函数 header 函数的兼容版