1. Go to this page and download the library: Download nullform/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/ */
nullform / http-status example snippets
use Nullform\HttpStatus;
// some code...
if ($response->getStatusCode() == HttpStatus::OK) {
// some code...
} else {
$error = HttpStatus::getDescription($response->getStatusCode());
}
HttpStatus::isInformational(int $status): bool
HttpStatus::isSuccessful(int $status): bool
HttpStatus::isRedirection(int $status): bool
HttpStatus::isClientError(int $status): bool
HttpStatus::isServerError(int $status): bool
HttpStatus::getReason(int $status): string
HttpStatus::getDescription(int $status): string
HttpStatus::getAllReasons(): string[]
HttpStatus::getAllDescriptions(): string[]
use Nullform\HttpStatusCode;
// some code...
$status = new HttpStatusCode($response->getStatusCode());
if ($status->isSuccessful()) {
// some code...
} else {
throw new \Exception($status->getReason() . '. ' . $status->getDescription());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.