Home >Backend Development >PHP Tutorial >How to generate pseudo-static in PHP_PHP tutorial
Many virtual hosts do not support URL_rewrite I also saw a classic written by a friend yesterday It feels like too much code. I did some research on_SERVER during my free time. In fact, it can be very simplified Let’s take http://www.xxx.com/xxx/test.php/article.123456.html as an example. This format represents_GET ================================== CODE: $arr_path[0]:article
http://www.xxx.com/xxx/test.php/article.123456.html
http://www.xxx.com/xxx/test .php?article=123456
Which format is more handsome.
The code is as follows:
CODE: $path_info =$_SERVER["PATH_INFO"]; //Get PATH_INFO
/*Use regular expressions to match "/article.123456.html"*/
if(eregi(" ^/[a-z]{1,16}.[0-9]{1,16}.html$",$path_info)) {
echo "OK";
$get_path=substr($path_info, 1,-5);//Processing the shape: D Remove "/", ".html"
$arr_path=explode(.,$get_path);//Process it into an array for later use
//The following is printed out Array to see if we have made any mistakes. :cool:
foreach ($arr_path as $key=>$value){
echo $arr_path[.$key.]:.$value."< ;br >";
}
}else echo "NO";
The results are as follows
$arr_path[1]:123456
Use it directly as $_GET, haha. PHP generating pseudo-static is so simple