Use of the PathInfo parameter in PHP. The global variable $ _ SERVER [PATH_INFO] in PHP is a very useful parameter. many CMS systems use this parameter when beautifying their URLs. For the following URL: the global variable $ _ SERVER ['path _ info'] in h 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:
Reference content is as follows: 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 "; // LieHuo. NeT ?> |
Bytes. For the following URL: h...