U メソッドについて
function U($url,$vars='',$suffix=true,$redirect=false,$domain=false) {<br /> // 解析URL<br /> $info = parse_url($url);<br /> $url = !empty($info['path'])?$info['path']:ACTION_NAME;<br /> // 解析子域名<br /> if($domain===true){<br /> $domain = $_SERVER['HTTP_HOST'];<br /> if(C('APP_SUB_DOMAIN_DEPLOY') ) { // 开启子域名部署<br /> $domain = $domain=='localhost'?'localhost':'www'.strstr($_SERVER['HTTP_HOST'],'.');<br /> // '子域名'=>array('项目[/分组]');<br /> foreach (C('APP_SUB_DOMAIN_RULES') as $key => $rule) {<br /> if(false === strpos($key,'*') && 0=== strpos($url,$rule[0])) {<br /> $domain = $key.strstr($domain,'.'); // 生成对应子域名<br /> $url = substr_replace($url,'',0,strlen($rule[0]));<br /> break;<br /> }<br /> }<br /> }<br /> }<br /><br /> // 解析参数<br /> if(is_string($vars)) { // aaa=1&bbb=2 转换成数组<br /> parse_str($vars,$vars);<br /> }elseif(!is_array($vars)){<br /> $vars = array();<br /> }<br /> if(isset($info['query'])) { // 解析地址里面参数 合并到vars<br /> parse_str($info['query'],$params);<br /> $vars = array_merge($params,$vars);<br /> }<br /><br /> // URL组装<br /> $depr = C('URL_PATHINFO_DEPR');<br /> if($url) {<br /> if(0=== strpos($url,'/')) {// 定义路由<br /> $route = true;<br /> $url = substr($url,1);<br /> if('/' != $depr) {<br /> $url = str_replace('/',$depr,$url);<br /> }<br /> }else{<br /> if('/' != $depr) { // 安全替换<br /> $url = str_replace('/',$depr,$url);<br /> }<br /> // 解析分组、模块和操作<br /> $url = trim($url,$depr);<br /> $path = explode($depr,$url);<br /> $var = array();<br /> $var[C('VAR_ACTION')] = !empty($path)?array_pop($path):ACTION_NAME;<br /> $var[C('VAR_MODULE')] = !empty($path)?array_pop($path):MODULE_NAME;<br /> if(C('URL_CASE_INSENSITIVE')) {<br /> $var[C('VAR_MODULE')] = parse_name($var[C('VAR_MODULE')]);<br /> }<br /> if(C('APP_GROUP_LIST')) {<br /> if(!empty($path)) {<br /> $group = array_pop($path);<br /> $var[C('VAR_GROUP')] = $group;<br /> }else{<br /> if(GROUP_NAME != C('DEFAULT_GROUP')) {<br /> $var[C('VAR_GROUP')] = GROUP_NAME;<br /> }<br /> }<br /> }<br /> }<br /> }<br /><br /> if(C('URL_MODEL') == 0) { // 普通模式URL转换<br /> $url = __APP__.'?'.http_build_query($var);<br /> if(!empty($vars)) {<br /> $vars = http_build_query($vars);<br /> $url .= '&'.$vars;<br /> }<br /> }else{ // PATHINFO模式或者兼容URL模式<br /> if(isset($route)) {<br /> $url = __APP__.'/'.$url;<br /> }else{<br /> $url = __APP__.'/'.implode($depr,array_reverse($var));<br /> }<br /> if(!empty($vars)) { // 添加参数<br /> $vars = http_build_query($vars);<br /> $url .= $depr.str_replace(array('=','&'),$depr,$vars);<br /> }<br /> if($suffix) {<br /> $suffix = $suffix===true?C('URL_HTML_SUFFIX'):$suffix;<br /> if($suffix) {<br /> $url .= '.'.ltrim($suffix,'.');<br /> }<br /> }<br /> }<br /> if($domain) {<br /> $url = 'http://'.$domain.$url;<br /> }<br /> if($redirect) // 直接跳转URL<br /> redirect($url);<br /> else<br /> return $url;<br />}<br /><br />// URL重定向
$url = 'verify';<br />$info = parse_url($url);Array