PHP pseudo static notation code _php tips

Source: Internet
Author: User
Like this web page.
Http://www.jb51.net/soft.php/1,100,8630.html

The script that actually handles is soft.php parameter is 1,100,8630

Equivalent to soft.php?a=1&b=1=100&c=8630 just such URLs are too hard to remember. Search engines don't like it either.

True static just completely generates HTML.

Direct output when the client accesses. No scripting explanations. It can be very effective when traffic is very large (such as when you have millions of visits a day). In other words, the server side of the real existence of this HTML page.

Of course, the traffic on your site is not that big time. URL rewriting is the best approach (personal point of view, when large traffic can be considered load balance.) Same as no relationship)

There are many ways to attach URL rewriting, apache,iisrewrite. Even PHP scripts can be handled directly. For example, in the example above, the PHP script is processed directly (this method benefits from the heavy flow of the Web server directly reduce the pressure.) PS: It is also a personal point of view:

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

The following is an example of a program to explain the implementation of the PHP pseudo static method, in fact, this method I have in other forums before the community has sent

Procedure as an example:

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

Copy Code code as follows:

<?php
Using the server variable to get path_info information in this case,/1,100,8630.html is the part that follows the script name
if (@ $path _info =$_server["Path_info"]) {
Matching parameters
if (Preg_match ("/\/(\d+), (\d+), (\d+) \.html/si", $path _info, $arr _path)) {
$gid =intval ($arr _path[1]); Get a value of 1
$sid =intval ($arr _path[2]); Get a value of 100
$softid =intval ($arr _path[3]); Get a value of 8630
}else die ("path:error!");
Equivalent to soft.php?gid=1&sid=100&softid=8630
}else die (' path:nothing! ');
It's so simple. ~


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.