$__arr1 = explode("/",$_SERVER['REQUEST_URI']);
$__arr2 = array_reverse(explode(DIRECTORY_SEPARATOR,VANGV_ROOT));
$len = strlen($_SERVER['SERVER_PROTOCOL'])-strlen(substr($_SERVER['SERVER_PROTOCOL'],strpos($_SERVER['SERVER_PROTOCOL'],'/'),strlen($_SERVER['SERVER_PROTOCOL'])));
$protocol = strtolower(substr($_SERVER['SERVER_PROTOCOL'],0,$len));
$vcet_location = $protocol.'://'. $_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']=="80"?"":':'.$_SERVER['SERVER_PORT']).'/';
for($___i=1; $___i<count($__arr1); $___i++){
if($__arr1[$___i] === $__arr2[$___i]){
$vcet_location .= "{$__arr1[$___i]}/";
}
}
$vcet_location = substr($vcet_location,0,-1);
unset($__arr1);unset($__arr2);unset($len);unset($protocol);

解决方案 »

  1.   

    /* 变量初始化(包含头文件)
    ...
    ...
    ... 
    */
    $__arr1 = explode("/",$_SERVER['REQUEST_URI']); 
    $__arr2 = array_reverse(explode(DIRECTORY_SEPARATOR,VANGV_ROOT)); 
    $len = strlen($_SERVER['SERVER_PROTOCOL'])-strlen(substr($_SERVER['SERVER_PROTOCOL'],strpos($_SERVER['SERVER_PROTOCOL'],'/'),strlen($_SERVER['SERVER_PROTOCOL']))); 
    $protocol = strtolower(substr($_SERVER['SERVER_PROTOCOL'],0,$len)); 
    $vcet_location = $protocol.'://'. $_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']=="80"?"":':'.$_SERVER['SERVER_PORT']).'/'; 
    for($___i=1; $___i <count($__arr1); $___i++){ 
    if($__arr1[$___i] === $__arr2[$___i]){ 
    $vcet_location .= "{$__arr1[$___i]}/"; 


    $vcet_location = substr($vcet_location,0,-1); 
    unset($__arr1);unset($__arr2);unset($len);unset($protocol);/* ...函数封装 
        ...
       ... */