本文实例讲述了使用纯php代码实现页面伪静态的方法。分享给大家供大家参考。具体如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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程序设计有所帮助。