Luminova Framework

HTTP Status Codes

Last updated: 2024-05-06 16:12:55

The HttpCode class is a helper class that provides a list of HTTP status codes and their corresponding messages. You can access this list by using the public property $codes, or by calling the get() method with null to retrieve all status codes and messages, or with a specific status code to retrieve its message.

Additionally, you can use magic getter methods like HttpCode::status200() to directly retrieve the message of a specific status code.

  • Class namespace: \Luminova\Http\HttpCode
  • This class is marked as final and can't be subclassed
  • This class is a Final class



Http status code.

public static array<int,string>$codes = [
    200 => 'OK',



Return a status code title, if $code is null return array of all status codes and it title.

public static get(int|null $code = null): string|null|array


$codeint|nullStatus code.

Return Value:

string|null|array - Status code title or array of status codes.


Get a status code title using a fancy magic method call. The xxx represent the status code you want to return it title

public static status[xxx](): string|null

Return Value:

string|null - Status code title.

Note: When using the magic call method, prefix status with the code you want to retrieve.

e.g. you need to type status following by the status code int HttpCode::status404().


array with all status codes and messages

// OR
var_dump((new HttpCode())->codes);

Returning status name for HTTP 200 status code.

    echo HttpCode::status200(); // OK

Returning status name for HTTP 503 status code.

    echo HttpCode::status503(); // Service Unavailable
echo HttpCode::get(400); // Bad Request