How to use header () in PHP
Editor to share with you how to use header () in PHP, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Using PHPheader () function to realize the error prompt function of page 404
Phpheader404 is written:
Header ("HTTP/1.1404NotFound"); exit
If the above code doesn't work, try the following code:
Header ("Status:404NotFound")
You'd better write both pieces of code. Why can one piece of code work and one piece of code not? I don't know, but the best way to write it is as follows:
Header ("HTTP/1.1404NotFound")
Header ("Status:404NotFound")
Exit
By the way, this code must be executed before any output!
For more information on the use of phpheader functions, please refer to: http://tuzwu.iteye.com/blog/search?query=header
What the http status code represents (found on w3.org, authoritative enough):
* 1xxvir InformationalMutual Requestreceivedcontinuing process
* 2xxvir SuccessWassuccessfullyreceivedUnderstood
Andaccepted
* 3xx:Redirection-Furtheractionmustbetakeninorderto
Completetherequest
* 4xx:ClientError-Therequestcontainsbadsyntaxorcannotbe
Fulfilled
* 5xx:ServerError-Theserverfailedtofulfillanapparently
Validrequest
| | "100"; Continue |
Phpheader404 similar function
| | "101"; SwitchingProtocols |
| | 2000s; OK |
| | 201 "; Created |
| | 202 "; Accepted |
| | 203 "; Non-AuthoritativeInformation |
| | "204"; NoContent |
| | "205"; ResetContent |
| | 206mm; PartialContent |
| | "300"; MultipleChoices |
| | 301; MovedPermanently |
The above is all the contents of the article "how to use header () in PHP". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!