PHP code example of slexx / headers

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

    

slexx / headers example snippets


$headers = new Slexx\Headers\Headers("Content-Type: image/jpeg\r\nAccept-Charset: utf-8\r\nX-My-Custom-Header: Zeke are cool");

echo $headers->get('Content-Type');
// -> image/jpeg

use Slexx\Headers\Headers;

var_dump(Headers::parse("Content-Type: image/jpeg\r\nAccept-Charset: utf-8\r\nX-My-Custom-Header: Zeke are cool"));
var_dump(Headers::parse([
    'Content-Type: image/jpeg',
    'Accept-Charset: utf-8',
    'X-My-Custom-Header: Zeke are cool'
]));

$headers = new Headers([
    'Content-Type: image/jpeg',
    'Accept-Charset: utf-8',
    'X-My-Custom-Header: Zeke are cool'
]);
foreach($headers as $name => $value) {
    echo "$name: $value\r\n";
}