Summary of Url and physical path obtained in PHP _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.