PHP code example of ph-7 / php-http-response-header
1. Go to this page and download the library: Download ph-7/php-http-response-header 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/ */
ph-7 / php-http-response-header example snippets
use PH7\PhpHttpResponseHeader\Header;
// Sends "200 OK" header to the browser
Http::setHeadersByCode(200);
// ...
// Send "201 Created" header
Http::setHeadersByCode(201);
// ...
// Sends "404 Not Found" to the browser
Http::setHeadersByCode(404);
// ...
// Sends "400 Bad Request" header to the browser
Http::setHeadersByCode(400);
// and so on ...
use PH7\PhpHttpResponseHeader\Header;
// Send 503, Service Temporarily Unavailable to the browser mentioning that you are doing a maintenance (good practice!)
Http::setMaintenanceCode($maintenanceTimeSeconds: 360);
use PH7\PhpHttpResponseHeader\Header;
// The HTTP server protocol
Http::getProtocol()
use PH7\PhpHttpResponseHeader\Header;
// Send "Content-Type: application/json" header to the browser
Http::setContentType('application/json');
// Send "Content-type: text/xml" to the browser
Http::setContentType('text/xml');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.