How to generate pseudo-static PHP Tutorial

Source: Internet
Author: User
How PHP generates pseudo-static data. Many virtual hosts do not support URL_rewrite. yesterday I saw a classic friend who wrote too much code. I did nothing to study _ SERVER. In fact, it can be very simplified to get www.xxx.com.

Many virtual hosts do not support URL_rewrite.

Yesterday, I saw a classic friend write

I feel that there are too many codes.

I have studied _ SERVER. it can be simplified.

Let's talk about it at http://www.xxx.com/xxx/test.php/article.123456.html.

In this format, _ 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 shape: D remove "/", ". html"
$ Arr_path = explode (., $ get_path); // process it as an array for backup
// Print out the array below to see if we have made a mistake.: cool:
Foreach ($ arr_path as $ key => $ value ){
Echo $ arr_path [. $ key.]:. $ value ."
";
}
} Else echo "NO ";
The result is as follows:

CODE: $ arr_path [0]: article
$ Arr_path [1]: 123456
Use $ _ GET directly. it's so easy to generate pseudo-static in PHP.

Yesterday I also saw a classic friend wrote a feeling that the code is too much. nothing to study the _ SERVER. In fact, it can be very simplified to take http://www.xxx.com...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.