PHP code example of krak / http-message

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

    

krak / http-message example snippets




use Krak\HttpMessage;

// grab from a psr http message
$accept_header = HttpMessage\AcceptHeader::fromHttpMessage($psr_req);
// parse from a string
$accept_header = HttpMessage\AcceptHeader::fromString('text/*;q=0.1,text/html;q=0.2');

// You can then sign an http message with the header, which will write the value of the header into the req.
$req = $accept_header->signHttpMessage($req);

// You can also export the header as a string
echo $accept_header;