Home > Backend Development > PHP Tutorial > PHP pseudo-static writing method with code_PHP tutorial

PHP pseudo-static writing method with code_PHP tutorial

WBOY
Release: 2016-07-21 15:51:54
Original
878 people have browsed it

For example, this web page
http://www.jb51.net/soft.php/1,100,8630.html

In fact, the script processed is soft.php and the parameter is 1,100,8630

Equivalent to soft.php?a=1&b=1=100&c=8630 but this URL is too difficult to remember. Search engines don’t like it either.

True static is just fully generated HTML.

Output directly when accessed by the client. No need for script explanation. It will have very good results when the traffic is very large (such as when there are millions of visits every day). In other words, this HTML page actually exists on the server side.

Of course when the traffic of your website is not that large. URL rewriting is the best method (in my personal opinion, load balancing can be considered when there is large traffic. It doesn't matter either)

There are many ways to rewrite URLs, including APACHE and IISREWRITE. Even PHP scripts can handle it directly. For example, in the above example, the PHP script handles it directly (the advantage of this method is that it directly reduces the pressure on the WEB server when there is a large amount of traffic. PS: This is also a personal opinion:

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

Let’s take the program as an example. PHP pseudo-static program implementation method. In fact, I have posted this method in other forum communities before

program as an example:

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

Copy code The code is as follows:

// Use the server variable to obtain the PATH_INFO information. In this example, it is /1,100,8630.html, which is the part after the execution script name
if(@$path_info =$_SERVER["PATH_INFO"]){
//Regular match 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!');
//That's it It’s so simple ~)


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319069.htmlTechArticleFor example, this page http://www.jb51.net/soft.php/1,100,8630.html actually handles The script's soft.php parameter is 1,100,8630, which is equivalent to soft.php?a=1c=8630, but such a URL is too difficult to remember. Search leads...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template