How to use header to send header information in PHP

Source: Internet
Author: User
As described in PHPBIBLE by Mr. Peng Wuxing, the header can send the Status header, such? Phpheader (Status: 404 NotFound );? In this way, the user's browser can see the 404 error that the file cannot be found, but I tried this. Later, I checked the relevant http information on w3.org, and finally found out how the Header Status code (Status) was described in Mr. Peng Wuxing's "PHP BIBLE, the header can send the Status header, as shown in figure

Header ("Status: 404 Not Found ");

?>

In this way, the user's browser can see the 404 error that the file cannot be found, but I tried this.

Later, I checked the relevant http information on w3.org and finally found out how to output the Status code (Status) in the Header to share with you.

It should actually be like this:

Header ("http/1.1 403 Forbidden ");

?>

The first part is the HTTP Version)

The second part is Status code)

Part 3: Reason Phrase (Reason-Phrase)

Separate the three parts with a space in the middle, and there is no carriage return in the middle. The first part and the second part are required. The third part is for people to see and can be written or not written or even written in disorder.

Also, the output of this sentence must be in the first line of the Html file.

Below I will show the meaning of each code (it was found on w3.org and authoritative enough ):

* 1xx: Informational-Request received, continuing process

* 2xx: Success-The action was successfully pinned ed, understood,

And accepted

* 3xx: Redirection-Further action must be taken in order

Complete the request

* 4xx: Client Error-The request contains bad syntax or cannot be

Fulfilled

* 5xx: Server Error-The server failed to fulfill an apparently

Valid request


| "100"; Continue

| "101"; Switching Protocols

| & Quot; 200 & quot; OK

| & Quot; 201 & quot; Created

| "202"; Accepted

| "203"; Non-Authoritative Information

| "204"; No Content

| & Quot; 205 & quot; Reset Content

| "206"; Partial Content

| "300"; Multiple Choices

| "301"; Moved Permanently

| "302"; Moved Temporarily

| "303"; See Other

| & Quot; 304 & quot; Not Modified

| "305"; Use Proxy

| "400"; Bad Request

| "401"; Unauthorized

| "402"; Payment Required

| "403"; Forbidden

| "404"; Not Found

| "405"; Method Not Allowed

| & Quot; 406 & quot; Not Acceptable

| "407"; Proxy Authentication Required

| "408"; Request Time-out

| "409"; Conflict

| "410"; Gone

| "411"; Length Required

| "412"; Precondition Failed

| "413"; Request Entity Too Large

| & Quot; 414 & quot; Request-URI Too Large

| "415"; Unsupported Media Type

| "500"; Internal Server Error

| "501"; Not Implemented

| & Quot; 502 & quot; Bad Gateway

| "503"; Service Unavailable

| "504"; Gateway Time-out

| "505"; HTTP Version not supported

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.