PHP code example of iothost / phpresponse
1. Go to this page and download the library: Download iothost/phpresponse 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/ */
iothost / phpresponse example snippets
$loader = = new \Iothost\PhpResponse\Response();
// add header
$response->addHeader('Cache-Control: no-cache');
// set Content-Type, can be entered as a string
$response->addHeader($response::CT_TEXT);
// set HTTP status code, can be entered as a number (int)
$response->setStatus($response::STATUS_OK);
// set response body as a string
$response->setBody($string);
// OR
// set response body as JSON (from array)
$response->setBodyJson($array);
// send response
$response->send();