PHP code example of perf / http-status

1. Go to this page and download the library: Download perf/http-status 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/ */

    

perf / http-status example snippets




use perf\HttpStatus\HttpStatusRepository;

$repository = HttpStatusRepository::createDefault();

$httpStatus = $repository->get(404);

echo $httpStatus->getReason(); // Will print "Not Found"
echo $httpStatus->toHeader(); //  Will print "HTTP/1.1 404 Not Found"



use perf\HttpStatus\HttpStatusRepository;

$httpStatus = HttpStatusRepository::createDefault()->get(404);

echo $httpStatus->getReason(); // Will print "Not Found"
echo $httpStatus->toHeader(); //  Will print "HTTP/1.1 404 Not Found"