PHP outputs http status codes and common status codes

WBOY
Release: 2016-08-08 09:19:39
Original
2761 people have browsed it
header("HTTP/1.1 403 Forbidden");
echo <<<sql
        <!DOCTYPE html>
        <html lang="en">
        	<head>
        		<meta charset="utf-8">
				<meta name="viewport" c minimum-scale=1, width=device-width">
				<title>Error 404 Not Found</title>
			</head>
			<body>
		  		<H1>Not Found</H1> <p><ins>That’s an error.</ins></p>
		  		<p>The requested URL <code><?php echo dirname({$_SERVER["SCRIPT_NAME"]});?></code> was not found on this server.  
		  		<ins>That’s all we know.</ins></p>
		  	</body>
		</html>
        <HTML>
            <HEAD>
                <meta charset="utf-8">
                <TITLE>404 Not Found</TITLE>
            </HEAD>
            <BODY>
                <H1>Not Found</H1>
                    The requested URL <?php echo dirname({$_SERVER["SCRIPT_NAME"]});?> was not found on this server.<P>
                <HR>
                <ADDRESS>Web Server at {$_SERVER["SERVER_NAME"]} Port {$_SERVER["SERVER_PORT"]}</ADDRESS>
            </BODY>
        </HTML>
sql;
Copy after login

http://www.w3.org/Protocols/rfc2616/rfc2616
Hypertext Transfer Protocol -- HTTP/1.1
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
100-199 Used to specify certain actions that the client should respond to.
200-299 is used to indicate successful understanding and acceptance of the request.
300-399 is used for files that have been moved and is often included in the location header information to specify the new address information.
400-499 is used to indicate client errors.
500-599 is used to support server errors.
[Informational 1xx] Informational
100="Continue" Continue: If the server receives a request with 100-continue in the header, this means that the client asks whether it can send attachments in subsequent requests. In this case, the server uses 100 (SC_CONTINUE) to allow the client to continue or 417 (Expectation Failed) to tell the client that it does not agree to accept the attachment. This status code is new in HTTP 1.1.
101="Switching Protocols" Switching protocols: The server understands and is willing to comply with the client's requirements and change the application protocol used in this connection by upgrading the message header field.
[Successful 2xx] Success
>>>200="OK" Success
201="Created" Created: The request has been completed, resulting in the creation of a new resource. Its URL should be given in the positioning header information.
202="Accepted" Accepted: The processing request has been accepted, but the processing has not been completed.
203="Non-Authoritative Information" Non-authorized information
>>>204="No Content" No content: The server has completed the request, but did not return any content.
205="Reset Content" Reset content: The server has completed the request, and the user agent should reset the document view that caused the request, used to force the browser to clear the form fields. This is new in HTTP 1.1.
206="Partial Content" Partial Content: Sent when the server completes a partial request containing Range header information
[Redirection 3xx] Redirect
300="Multiple Choices" Multiple Choices: Indicates that the requested document can Found in multiple places and will be listed in the returned document. If the server has preferences, the preferences will be listed in the location response header.
>>>301="Moved Permanently" Permanently moved: The requested resource is assigned a new permanent URI and any future references to this resource should use this returned URI. The browser will automatically connect to the new URL. NOTE: When automatically redirecting a POST request that receives a 301 status code, some existing HTTP/1.0 user agents will incorrectly change that to a GET request
>>>302="Found" Found: Requested resource Temporarily resides in a temporary URI. Somewhat similar to 301, except that the URL given in the positioning header information should be understood as a temporary exchange address rather than a permanent one. Note: In HTTP 1.0, messages are moved temporarily (Moved Temporarily) rather than discovered
303="See Other" See Other: The response to this request can be at a different URI and should be retrieved using the GET method of the resource . Similar to 301 and 302, except that if the original request was POST, the new document (given in the positioning header information) must be retrieved using GET. This status code is new to HTTP 1.1.
>>>304="Not Modified" Not modified: If the client performs a GET request conditionally and allows access, but the file has not been modified, the server should respond with this status code.
305="Use Proxy" Use proxy: The location field of the requested resource must be accessed through a proxy. New in HTTP 1.1.
306="(Unused)" (Unused) The 306 status code uses the previous version of the specification and is no longer used. The code is reserved
307="Temporary Redirect" Temporary redirection: The requested resource temporarily resides in a Different URIs. The rules for browsers to handle 307 status are the same as 302. The 307 status was added to HTTP 1.1 because many browsers performed an incorrect redirect when receiving a 302 response, even when the original message was a POST. The browser is assumed to redirect on a POST request only if a 303 response is received. The purpose of adding this new status code is clear: when the response is 303, it will be redirected to GET and POST requests; when the response is 307, it will be redirected to GET requests instead of POST requests.
[Client Error 4xx] Client error
>>>400="Bad Request" The server does not understand the syntax of the request.
>>>401="Unauthorized" Unauthorized: The request requires user authentication. If the request already contains an authorization certificate, the 401 response indicates that the credentials have been rejected. This response must contain a WWW-Authenticate authorization header.
402="Payment Required" Payment required: This code is reserved for future use.
>>>403="Forbidden" Forbidden: The server understands the request, but refuses to fulfill it.
>>>404="Not Found"
405="Method Not Allowed" Not allowed: The method specified in the request line is not allowed to request the resource identified by the URI. Indicates that the request method (GET, POST, HEAD, PUT, DELETE, etc.) is not allowed for certain resources.
406="Not Acceptable" Not acceptable: Indicates that the MIME type of the requested resource is inconsistent with the type specified in the Accept header information in the client.
407="Proxy Authentication Required" Proxy Authentication: This code is similar to 401 (Unauthorized), but means that the client must authenticate it first.
408="Request Timeout" Request timeout: The client did not generate a request during the time the server was ready to wait. New in HTTP 1.1.
409="Conflict" Conflict: The request cannot be completed due to a conflict with the current state of the resource. This status is usually used with PUT requests. The 409 status is often used when trying to upload an incorrect version of a file. This status code is new to HTTP 1.1.
>>>410="Gone" Gone: The requested resource is no longer an available server and has no forwarding address. Tells the client that the requested document no longer exists and has no updated address. The 410 status is different from 404. 410 is used when the guidance document has been moved, while 404 is used for inaccessibility for unknown reasons. This status code is new to HTTP 1.1.
411="Length Required" Length required: The server refuses to accept the request without defining the content length. Indicates that the server cannot process the request (assuming a POST request with an attachment) unless the client sends a Content-Length header indicating the size of the data to be sent to the server. This state is new to HTTP 1.1.
412="Precondition Failed" Precondition failed: The precondition given in one or more request header fields when one or more request header fields are tested on the server. Indicates that certain prerequisites in the request headers are incorrect. This state is new to HTTP 1.1.
413="Request Entity Too Large" The request entity is too large: Tells the client that the requested document is larger than the server currently wants to process. If the server thinks it can be processed after a while, it will include a Retry-After response header. This state is new to HTTP 1.1.
414="Request-URI Too Long" The request URI is too long: The status is used when the URI is too long. The "URI" referred to here refers to the content after the host, domain name and port number in the URL. Newly added to HTTP 1.1.
415="Unsupported Media Type" Unsupported media type: The format type of the attachment attached to the request is not known by the server. This state is new to HTTP 1.1.
416="Requested Range Not Satisfiable" The request range does not meet: Indicates that the client contains a request with Range header information that the server cannot satisfy. This state is new to HTTP 1.1.
417="Expectation Failed" Expectation failure: If the server gets an Expect request header with a 100-continue value, this means that the client is asking whether it can send attachments in subsequent requests. In this case, the server will also use the status (417) to tell the browser that the server does not accept the attachment or use the 100 status to tell the client that it can continue to send the attachment. This state is new to HTTP 1.1.
[Server Error 5xx] Server Error
>>>500="Internal Server Error" Internal Server Error
>>>501="Not Implemented" Unable to execute: The server does not support the functionality required to complete the request . Tells the client that the server does not support the functionality requested in the request. For example, the client executes a command such as PUT that the server does not support.
>>>502="Bad Gateway" Bad Gateway: The server, acting as a gateway or proxy, received an invalid response from the upstream server while trying to satisfy the access request. This status indicates that the receiving server received an error response from the remote server.
>>>503="Service Unavailable" Service Unavailable: The server is currently unable to process requests due to temporary overload or server maintenance. Some servers may wish to simply refuse the connection. For example, the server should return this header if some threads or database connection pools are no longer free. The server can provide a Retry-After header to tell the client when it can try again.
504="Gateway Timeout" Gateway timeout: It indicates that the receiving server did not get a timely response from the remote server. This state is new to HTTP 1.1.
505="HTTP Version Not Supported" HTTP version is not supported: The server does not support, or refuses to support, the version of the HTTP protocol that is used in the request message. This state is new to HTTP 1.1.
Concise version:
Successful 2XX status code that successfully processed the request.
200 The server has successfully processed the request and served the requested web page.
204 The server successfully processed the request but did not return anything. 每 The redirection of the redirection to the 3xx request for each request should not be used for more than 5 times.
301 The requested web page has been permanently moved to a new location. When URLs change, use the 301 code. Save the new URL in the search engine index.
302 The requested web page is temporarily moved to a new location. The original URL is saved in the search engine index.
304                                                                                                                                                                                              llllllllllllll out out out of 304 to be saved if the web page has not been updated since the requester's last request. This can save bandwidth and overhead.
Client error 4XX indicates that the request may be in error, hindering the server's processing.
400 The server does not understand the syntax of the request.
403 The server rejected the request.
404 The server cannot find the requested web page. This code is often returned for web pages that do not exist on the server.
410 The server returns this response after the requested resource is permanently deleted. This code is similar to the 404 (Not Found) code, but is sometimes used in place of the 404 code when the resource previously existed but now does not. If a resource has been permanently deleted, 301 should be used to specify the resource's new location.
Server error 5XX means that an internal error occurred while the server was processing the request. These errors may be errors on the server itself rather than an error in the request.
500 The server encountered an error and was unable to complete the request.
503 The server is currently unavailable (due to overload or downtime for maintenance). Often, this is a temporary state.
Detailed breakdown:
2XX Success
200 Normal; request completed.
201 Normal; immediately followed by POST command.
202 Normal; accepted for processing, but processing has not yet been completed.
203 Normal; partial information — The information returned is only part of it.
204 Normal; No response - The request has been received, but there is no information to be sent back.
3XX Redirects
301 Moved — The requested data has a new location and the change is permanent.
302 Found — The requested data temporarily has a different URI.
303 See Other — The response to the request can be found under another URI and should be retrieved using the GET method.
304 Not Modified — The document was not modified as expected.
305 Use proxy — The requested resource must be accessed through the proxy provided in the location field.
306 Unused — No longer used; retain this code for future use.
4XX Errors in the client
400 Bad Request — There is a syntax problem in the request, or the request cannot be fulfilled.
401 Unauthorized — The client is not authorized to access data.
402 Payment Required — Indicates that the billing system is in effect.
403 Forbidden — No access required even with authorization.
404 Not Found — The server cannot find the given resource; the document does not exist.
407 Proxy Authentication Request — The client must first authenticate itself using a proxy.
415 Unsupported media type — The server refused to service the request because the format of the requested entity is not supported.
5XX Errors in the server
500 Internal error — The server cannot complete the request due to unexpected circumstances.
501 Not executed — The server does not support the requested tool.
502 Bad Gateway — The server received an invalid response from the upstream server.
503 Unable to obtain service — The server was unable to process the request due to temporary overload or maintenance.
504 Gateway Timeout
When a server working as a gateway or proxy tries to execute a request, it fails to receive a response in time from the upstream server (the server identified by the URI, such as HTTP, FTP, LDAP) or the auxiliary server (such as DNS).
Note: Some proxy servers will return a 400 or 500 error when a DNS query times out
505 HTTP Version Not Supported
The server does not support, or refuses to support, the HTTP version used in the request. This implies that the server is unable or unwilling to use the same version as the client. The response should contain an entity describing why the version is not supported and what protocols the server supports.
506 Variant Also Negotiates
Extended by the Transparent Content Negotiation Protocol (RFC 2295) and represents an internal configuration error in the server: the requested negotiation variable resource is configured to use itself in transparent content negotiation, and therefore in a negotiation process Not an appropriate focus.
507 Insufficient Storage
The server cannot store the content necessary to complete the request. This condition is considered temporary. WebDAV (RFC 4918)
508 Loop Detected
The server found an infinite loop in the request
509 Bandwidth Limit Exceeded
The server reached the bandwidth limit. This is not an official status code, but is still widely used.
510 Not Extended
The strategies required to obtain resources are not satisfied. (RFC 2774)

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces the http status code output by PHP and common status codes, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!