Here are some of the most commonly used HTTP error codes and their corresponding constant names in PHP:
400 Bad Request: HTTP_BAD_REQUEST 401 Unauthorized: HTTP_UNAUTHORIZED 403 Forbidden: HTTP_FORBIDDEN 404 Not Found: HTTP_NOT_FOUND 500 Internal Server Error: HTTP_INTERNAL_SERVER_ERROR 502 Bad Gateway: HTTP_BAD_GATEWAY 503 Service Unavailable: HTTP_SERVICE_UNAVAILABLE
To use the predefined HTTP error codes in PHP, you can use the constant names in the http_response_code() function. For example, to set the HTTP response code to 404 Not Found, you can use the following code: