Get the App
SLTechnology News&Howtos  ›  Development  › 

How php returns an error code

Shulou Source: shulou.com Published: 2022-06-03 14:15:30 11月14日 Update

This article mainly introduces how php returns the error code, the article is very detailed, has a certain reference value, interested friends must read it!

1. You can add 404 header information to the return page with the header () function.

2. Prompt the browser that the web page cannot be found.

So you can use:

Header ("HTTP/1.0 404 Not Found")

Or:

Header ("Status: 404 Not Found")

The latter is used in FastCGI mode, and two sentences can be written directly at the same time in php code.

The instructions for header are as follows:

The header string.There are two special-case header calls. The first is a header that starts with the string "HTTP/" (case is not significant), which will be used to figure out the HTTP status code to send. For example, if you have configured Apache to use a PHP script to handle requests for missing files (using the ErrorDocument directive), you may want to make sure that your script generates the proper status code.For FastCGI you must use the following for a 404 response:

And header ("Location: xxx.com"); the default is to do 302 state jump, so it can not output 404 error status to the browser.

The above is all the contents of the article "how php returns error codes". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Code error content browser status article browse value usage instructions information interest function at the same time guys buddies is in more patterns knowledge web pages Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information OPPO Reno MySQL Shulou Technology