How to header out status code in PHP (GO)

Source: Internet
Author: User
Tags php tutorial

---restore content starts---

As described in Mr. Pengwuchen's PHP (PHP tutorial) BIBLE, the header can send a status header, such as

Header ("status:404 not Found");

?>

Can let the user browser appear the file cannot find the 404 error, but I tried this is not possible.

Later I went to w3.org to check the relevant information on the HTTP, finally tried out how to header out status code (status), share with you.

In fact it should be this:

Header ("http/1.1 403 Forbidden");

?>

The first version of the HTTP Protocol (http-version)

Part Two is the status code

Part Three is a reason phrase (reason-phrase)

Three parts in the middle with a space to separate, and the middle can not have a carriage return, the first part and the second part is necessary, the third part is for people to read, can write not write or even write.

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

Here I give the meaning of the code (from the w3.org, enough authority):

* 1xx:informational-request received, continuing process

* 2xx:success-the Action was successfully received, understood,

and accepted

* 3xx:redirection-further action must be taken on order to

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

| "200"; Ok

| "201"; Created

| "202"; Accepted

| "203"; Non-authoritative Information

| "204"; No Content

| "205"; Reset Content

| "206"; Partial Content

| "300"; Multiple Choices

| "301"; Moved Permanently

| "302"; Moved temporarily

| "303"; See other

| "304"; Not Modified

| "305"; Use Proxy

| "400"; Bad Request

| "401"; Unauthorized

| "402"; Payment Required

| "403"; Forbidden

| "404"; Not Found

| "405"; Method not allowed

| "406"; 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

| "414"; Request-uri Too Large

| "415"; Unsupported Media Type

| "500"; Internal Server Error

| "501"; Not implemented

| "502"; Bad Gateway

| "503"; Service unavailable

| "504"; Gateway time-out

| "505"; HTTP Version not supported

---restore content ends---

How to header out status code in PHP (GO)

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.