Home  >  Article  >  Backend Development  >  How to generate pseudo-static in PHP_PHP tutorial

How to generate pseudo-static in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:35:381009browse

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
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

CODE: $arr_path[0]:article
$arr_path[1]:123456
Use it directly as $_GET, haha. PHP generating pseudo-static is so simple

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508297.htmlTechArticleMany virtual hosts do not support URL_rewrite. Yesterday, I also saw a classic article written by a friend and felt that there was too much code. Nothing happened. I did some research on_SERVER. In fact, it can be very simplified and get http://www.xxx.com...
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