The global variable $_server[' path_info ' in PHP is a useful parameter, and many CMS systems use this parameter when beautifying their URLs.
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 ', and at this time $_server[' query_string '] = ' c=index&m=search ';
Usually, when we first start writing PHP programs, we use URLs like Http://www.test.com/index.php?c=search&m=main, which not only look very strange, And it's also very unfriendly to search engines. Many search engines ingest, will ignore the content after query string, although Google will not ignore query string, but for other pages without query string, will give a higher PR value.
Here is a very 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";
?>
Resources:
1. PHP Parse Pathinfo
2, CPAN PathInfo