PHP pseudo-static writing with code _ PHP Tutorial

Source: Internet
Author: User
PHP pseudo-static writing with code. For example, if this web page www.jb51.netsoft.php1,100,8630.html is actually processing the script, the soft. php parameter is 1,100,863 0, which is equivalent to soft. php? A1c8630 is difficult to remember. Search leads to this webpage
Http://www.jb51.net/soft.php/1,100,8630.html

In fact, the soft. php parameter is 1,100,863 0.

Equivalent to soft. php? A = 1 & B = 1 = 100 & c = 8630, but such a URL is too hard to remember. Search engines do not like it either.

Real static only completely generates HTML.

Output directly when accessing the client. No script explanation is required. When the traffic is very large (for example, when there are millions of visits each day), it will play a very good effect. That is to say, the server actually has this HTML page.

Of course, when the traffic on your website is not that large. URL rewriting is the best method (in my opinion, server load balancer can be considered when the traffic is high. It also does not matter)

There are many URL rewriting methods, such as APACHE and IISREWRITE. Even PHP scripts can be processed directly. For example, in the above example, PHP scripts are directly processed (the advantage of this method is to directly reduce the pressure on the WEB server when the traffic is high. PS: Also personal opinion:

========================================================== ==========

The following uses a program as an example to describe the PHP pseudo-static program implementation method. In fact, this method has already been released in other forums.

Program example:

Http://www.jb51.net/soft.php/1,100,8630.html

The code is as follows:


// Use the server variable to obtain the PATH_INFO information. In this example, it is/, 8630.html, that is, the part after the execution script name.
If (@ $ path_info = $ _ SERVER ["PATH_INFO"]) {
// Regular expression matching parameters
If (preg_match ("// (\ d +), (\ d +), (\ d +) \. html/si", $ path_info, $ arr_path )){
$ Gid = intval ($ arr_path [1]); // get the value 1
$ Sid = intval ($ arr_path [2]); // get the value 100
$ Softid = intval ($ arr_path [3]); // get the value 8630
} Else die ("Path: Error! ");
// Equivalent to soft. php? Gid = 1 & sid = 100 & softid = 8630
} Else die ('path: Nothing! ');
// It's that simple .~)



The compaction http://www.jb51.net/soft.php/1,100,8630.html actually processes the script as soft. php parameter is 1,100,863 0 equivalent to soft. php? A = 1c = 8630 but such a URL is too hard to remember. Search reference...

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.