The global variable $ _ SERVER ['path _ info'] in PathInfo PHP in PHP is a very useful parameter. when many CMS systems beautify their URLs, this parameter is used.
For the following URL:
Http://www.test.com/index.php/foo/bar.html? C = index & m = search
We can get $ _ SERVER ['path _ info'] = '/foo/bar.html ', in this case, $ _ SERVER ['query _ string'] = 'C = index & m = search ';
Usually, when we first started writing PHP programs, we would use http://www.test.com/index.php? C = search & m = main. this kind of URL is not only strange, but also unfriendly to search engines. When indexed by many search engines, the content after Query String is ignored. Although google does not ignore Query String, other pages without Query String are given a relatively high PR value.
The following is a simple code for parsing PATH_INFO:
If (! Isset ($ _ SERVER ['path_info']) {
$ Pathinfo = 'default ';
} Else {
$ Pathinfo = explode ('/', $ _ SERVER ['path_info']);
}
If (is_array ($ pathinfo) AND! Empty ($ pathinfo )){
$ Page = $ pathinfo [1];
} Else {
$ Page = 'A. php ';
}
Require "$ page. php ";
?>
References:
1. PHP Parse Pathinfo
2. CPAN PathInfo