PHP code example of irap / http

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

    

irap / http example snippets



http_response_code(iRAP/Http/HttpCode::NOT_FOUND);

$body = array(
    "result" => "error",
    "message" => "Resource not found.",
);

header('Content-Type: application/json');
die(json_encode($body));


use iRAP\Http\HttpCode;

http_response_code(HttpCode::NOT_FOUND);

$body = array(
    "result" => "error",
    "message" => "Resource not found.",
);

header('Content-Type: application/json');
die(json_encode($body));


use iRAP\Http\HttpCode;

if (HttpCode::isValid(404)) {
    echo "Valid HTTP status code";
} else {
    echo "Invalid HTTP status code";
}