Home  >  Article  >  php教程  >  纯php代码实现伪静态的方法

纯php代码实现伪静态的方法

PHP中文网
PHP中文网Original
2016-05-25 17:06:311704browse

本文实例讲述了使用纯php代码实现页面伪静态的方法。分享给大家供大家参考。具体如下:

if(1==URLROLE){
  $nav=$_SERVER["REQUEST_URI"];
  $script_name=$_SERVER["SCRIPT_NAME"];
  $nav1=ereg_replace(".html","",substr(ereg_replace("$script_name","",urldecode($nav)),1));
  $vars = @explode("/",$nav1);
  $_url = array_chunk($vars,2);
  $_GET['m'] = $vars[0]?$vars[0]:'index';
  //如果没有参数,默认访问index类库的index方法
  $_GET['a'] = $vars[1]?$vars[1]:'index';
  unset($_url[0]);
  if($_url){
    foreach($_url as $key=>$val){
      @$_GET[$val[0]] = $val[1];
    }
  }
//var_dump($_GET);
}

希望本文所述对大家的php程序设计有所帮助。

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