PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Ahmad Mustapha   PHP HTTP Status Code Constants Class   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Read me
Class: PHP HTTP Status Code Constants Class
Return HTTP status codes and their descriptions
Author: By
Last change:
Date: 1 year ago
Size: 891 bytes
 

Contents

Class file image Download

Http Status Codes

Enums of all official http status codes and their descriptions.

Installation

composer require ahmard/http-status-codes

Usage

<?php

require __DIR__ . '/vendor/autoload.php';


$sc = \HttpStatusCodes\StatusCode::CREATED;

// Get Status Code  =>  "201"
$sc->value;

$desc = $sc->describe();

// Get Status Code  =>  "201"
$desc->code;

// Get Status Code Title  => "Created"
$desc->title;

You can also get description of a given status code, the description is copied from Wikipedia.

<?php

$sc = \HttpStatusCodes\StatusCode::CREATED;

// Get Description  =>  "The request has been fulfilled, resulting in the creation of a new resource."
$sc->describe()->desc;