PHP and HTTP protocol

Source: Internet
Author: User

$_SERVERis an array of information such as header information (header), path, and script location (scripts locations), and so on.

Can be output in the background again

foreach ($_server as $key = $val)

echo "$key = $val <br/>";

See the HTTP protocol for two processing in the background. (the module in the background will encapsulate the accepted HTTP protocol two times.) In the output path, is the environment variable in the server. Key is the $REMOVE_ADDR value for the visitor's IP address. You can decide in the background to prohibit some IP visitors:

if ($_server[' remove_addr ']==192.168,1,100)

{

Do some processing, such as quitting directly, or jumping to another page

Page jumps are also part of the HTTP protocol

Header ("Location:somePage.php");

}

Generally use $_server[' document_root '] to obtain the path of the file in the server;

The specific parameters refer to the PHP manual (predefined variables).

2. Anti-theft chain reference

If you only want to visit the pages of this site, you can check the HTTP message body reference to determine, the following code

if (Isset ($_server[' http_referer '))

{

if (Strpos ($_server[' http_referer '), "http://localhost/www") ==0)

{

Description for site access to this site, you can continue to access

}

Else

{

Header ("Location:somePage.php");

}

}

The difference between 3.GET and post requests (there are other ways of requesting them, both of which are only common)

(1) The GET request is placed in the address bar. The POST request is placed inside the message body of the HTTP protocol.

(2) Size

The meaning of 4.header

The header is to write something into the HTTP message body, for example:

Header ("Location:somePage.php");

is to re-jump.

The status code returned to the browser is 302 instead of 200, so the jump happens to the client (browser).

5. Status Code

304 means the server did not update the file, and the file will no longer be sent to the browser.

PHP and HTTP protocol

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.