Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use header () in PHP

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report