-
- //伪静态方法一
- // localhost/jbxue/test.php?id|1@action|2
- $Php2Html_FileUrl = $_SERVER["REQUEST_URI"];
- echo $Php2Html_FileUrl."
";// /jbxue/test.php?id|1@action|2
- $Php2Html_UrlString = str_replace("?","",str_replace("/", "", strrchr(strrchr($Php2Html_FileUrl, "/"),"?")));
- echo $Php2Html_UrlString."
";// id|1@action|2
- $Php2Html_UrlQueryStrList = explode("@", $Php2Html_UrlString);
- print_r($Php2Html_UrlQueryStrList);// Array ( [0] => id|1 [1] => action|2 )
- echo "
";
- foreach($Php2Html_UrlQueryStrList as $Php2Html_UrlQueryStr)
- {
- $Php2Html_TmpArray = explode("|", $Php2Html_UrlQueryStr);
- print_r($Php2Html_TmpArray);// Array ( [0] => id [1] => 1 ) ; Array ( [0] => action [1] => 2 )
- echo "
";
- $_GET[$Php2Html_TmpArray[0]] = $Php2Html_TmpArray[1];
- }
- //echo '假静态:$_GET变量
';
- print_r($_GET); // Array ( [id|1@action|2] => [id] => 1 [action] => 2 )
- echo "
";
- echo "
";
- echo $_GET[id]."
";// 1
- echo $_GET[action];// 2
- ?>
复制代码
代码2,
-
-
- //伪静态方法二
- // localhost/jbxue/test.php/1/2
- $filename = basename($_SERVER['SCRIPT_NAME']);
- echo $_SERVER['SCRIPT_NAME']."
";// /jbxue/test.php
- echo $filename."
";// test.php
-
- if(strtolower($filename)=='test.php'){
- if(!emptyempty($_GET[id])){
- $id=intval($_GET[id]);
- echo $id."
";
- $action=intval($_GET[action]);
- echo $action."
";
- }else{
- $nav=$_SERVER['REQUEST_URI'];
- echo "1:".$nav."
";// /jbxue/test.php/1/2
- $script=$_SERVER['SCRIPT_NAME'];
- echo "2:".$script."
";// /jbxue/test.php
- $nav=ereg_replace("^$script","",urldecode($nav));
- echo $nav."
"; // /1/2
- $vars=explode("/",$nav);
- print_r($vars);// Array ( [0] => [1] => 1 [2] => 2 )
- echo "
";
- $id=intval($vars[1]);
- $action=intval($vars[2]);
- }
- echo $id.'&'.$action;
- }
- ?>
复制代码
1 2 下一页 尾页
|
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31