PHP code example of hyqo / http-headers

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

    

hyqo / http-headers example snippets


use Hyqo\Http\RequestHeaders;

$headers = new RequestHeaders(['Forwarded'=>'for=192.0.2.60; For="[2001:db8:cafe::17]:4711"; proto=https; host=foo.bar'])
$headers->forwarded->getFor(); //["192.0.2.60","[2001:db8:cafe::17]:4711"]
$headers->forwarded->getProto(); //"https"
$headers->forwarded->getHost(); //"foo.bar"

use Hyqo\Http\RequestHeaders;

$headers = new RequestHeaders(['X-Forwarded-For'=>'192.0.2.60, "[2001:db8:cafe::17]:4711"'])
$headers->forwarded->getFor()

use Hyqo\Http\RequestHeaders;

$headers = new RequestHeaders(['X-Forwarded-Proto'=>'https'])
$headers->forwarded->getProto()(); //https

use Hyqo\Http\RequestHeaders;

$headers = new RequestHeaders(['X-Forwarded-Prefix'=>'/foo'])
$headers->forwarded->getPrefix(); //"/foo"