PHP code example of codeinc / http-reason-phrase-lookup

1. Go to this page and download the library: Download codeinc/http-reason-phrase-lookup 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/ */

    

codeinc / http-reason-phrase-lookup example snippets



use CodeInc\Psr7ResponseSender\HttpReasonPhraseLookup;

// you can lookup a given status code 
HttpReasonPhraseLookup::getReasonPhrase(404); // returns 'Not Found'
HttpReasonPhraseLookup::getReasonPhrase(999); // returns null

// or list all the reason phrases
foreach (HttpReasonPhraseLookup::getReasonPhrases() as $statusCode => $reasonPhrase) {
    echo "$statusCode => $reasonPhrase\n";
}