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

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

WBOY
发布: 2016-06-08 17:29:41
原创
922 人浏览过

经典全面的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
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板