How to use header to send header information in PHP

Source: Internet
Author: User
Tags header
As described in Mr. Pengwuchen's PHP BIBLE, the header can send a status header, such as





header ("status:404 not Found");





?>





can make the user's browser appear file cannot find 404 error, but I tried this is not possible.





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





actually should be like this:





Header ("http/1.1 403 Forbidden");





?>




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





the second part is state code (status)





Part III is divided into causal phrases (reason-phrase)





three parts of 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 not write or even write.





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





below I give the meaning of each code (it is from the w3.org to find, 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 into 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 a 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";





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











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.