Summary of Url and physical path in PHP. Here I want to summarize some information about the path where the URL and file in the address bar belong to me: using $ _ SERVER [], we can accomplish many things: it is a header (headers here I want to summarize some information about the path where the URL and file in the address bar belong to me:
With $ _ SERVER [], we can accomplish many things: it is an array containing headers, path information, and script positions. the array entity is created by the web SERVER.
This is a "superglobal", or it can be described as an automatic global variable. This only means that it is valid in all scripts. You do not need to use global $ _ SERVER; to access a function or method, just like using $ HTTP_SERVER_VARS. $ HTTP_SERVER_VARS contains the same information, but it is not an automatic global variable. (Note: $ HTTP_SERVER_VARS and $ _ SERVER are different variables. PHP processes them differently .) If the register_globals command is set, these variables are also available in all scripts; that is, the $ _ SERVER and $ HTTP_SERVER_VARS arrays are separated.
$ _ SERVER ['http _ host'] retrieves the HOST of the current request: header content
$ _ SERVER ['php _ SELF '], which is probably the most frequently used one. it returns the name of the currently called page, for example, http: // localhost/test/2005/test. php,/test/2005/test will be returned. php
$ _ SERVER ['script _ name'] returns the path containing the current SCRIPT. This is useful when the page needs to point to itself.
$ _ SERVER ['script _ filename'] it returns the absolute path of the current file.
$ _ SERVER ['request _ URI '] returns the URI required to access this page, including "/"
Of course there are many path functions:
Dirname (), returns the directory section in the path information, which is prefixed "/"
Basename () returns the basic file name in the path. you can also set a suffix to control the output.
Realpath (), returns the path information of the absolutely normalized path
Pipeline uses $ _ SERVER [] to accomplish many things: it is a header (headers...