PHP code example of hyqo / http-codes

1. Go to this page and download the library: Download hyqo/http-codes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hyqo / http-codes example snippets


use Hyqo\Http\HttpCode;

echo HttpCode::OK->header(); //HTTP/1.0 200 OK
echo HttpCode::OK->header(1.1); //HTTP/1.1 200 OK
echo HttpCode::OK->header('http/1.1')); //HTTP/1.1 200 OK

use Hyqo\Http\HttpCode;

echo HttpCode::OK->header(); //HTTP/1.0 200 OK

$_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1"
echo HttpCode::OK->header(); //HTTP/1.1 200 OK

echo HttpCode::NOT_FOUND->message(); //Not Found
echo HttpCode::NOT_FOUND->version(); //1

HttpCode::IM_A_TEAPOT->value; //(int) 418
HttpCode::from(418)->message(); //(string) "I'm a teapot"