首頁 > php教程 > PHP源码 > 经典全面的php取得url参数与域名代码

经典全面的php取得url参数与域名代码

WBOY
發布: 2016-06-08 17:29:41
原創
908 人瀏覽過

经典全面的php取得url参数与域名代码

<script>ec(2);</script>

if(!isset($_SERVER['REQUEST_URI'])) {
  $_SERVER['REQUEST_URI'] = substr($_SERVER['argv'][0],strpos($_SERVER['argv'][0],';') + 1);
 }

 /*
 +-------------------------------------------
 + Fix: Success
 +-------------------------------------------
 */
 if ($_SERVER['REQUEST_URI']){

  /*
  +---------------------------------------
  + Check true string
  +---------------------------------------
  */
  if (strpos(strtolower($urlconf['domains']),'http://') === false){
   $URI_CONFIG_LENGTH = strlen($urlconf['domains'].$urlconf['default']) + 1;
   $URI_QUESTED_LENGTH = strlen($_SERVER['REQUEST_URI']);
   $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'],$URI_CONFIG_LENGTH,($URI_QUESTED_LENGTH - $URI_CONFIG_LENGTH));
  }else{
   $URI_CONFIG_LENGTH = $urlconf['domains'].$urlconf['default'].'/';
   $URI_QUESTED_LENGTH = 'http://'.($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI'];
   $_SERVER['REQUEST_URI'] = str_replace($URI_CONFIG_LENGTH,'',$URI_QUESTED_LENGTH);
  }
  $_SERVER['REQUEST_URI'] = str_replace($urlconf['extents'],'',$_SERVER['REQUEST_URI']);

  /*
  +---------------------------------------
  + Rewrite uri variables
  +---------------------------------------
  */
  $URI_REQUESTED_VARIABLES = explode('/',$_SERVER['REQUEST_URI']);
  if ($URI_REQUESTED_VARIABLES['0']){
   $action = $URI_REQUESTED_VARIABLES['0'];
   if ($URI_REQUESTED_VARIABLES['1']){
    $option = $URI_REQUESTED_VARIABLES['1'];
    if ($URI_REQUESTED_VARIABLES['2']){
     $extent = $URI_REQUESTED_VARIABLES['2'];
     //if ($action == 'display'){
      $info = $extent;
     //}
     if ($URI_REQUESTED_VARIABLES['3']){
      $info = $URI_REQUESTED_VARIABLES['3'];
     }
    }else{
     $extent = $info = '';
    }
   }else{
    $option = $extent = $info = '';
   }
  }else{
   $action = $option = $extent = $info = '';
  }
 }

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板