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

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

WBOY
WBOYOriginal
2016-06-08 17:29:41912browse

经典全面的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 = '';
  }
 }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn