PHP伪静态隐藏传递的参数名的四种方法_PHP
程序员文章站
2024-04-03 08:20:46
...
伪静态
PHP伪静态的使用主要是为了隐藏传递的参数名,今天介绍的PHP伪静态的方法总共有四种方法以加深对PHP伪静态的了解。
伪静态方法一:
//伪静态方法一 // localhost/php100/test.php?id|1@action|2 $Php2Html_FileUrl = $_SERVER["REQUEST_URI"]; echo $Php2Html_FileUrl." "; // /php100/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 ?> |