PHP code example of innmind / media-type

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

    

innmind / media-type example snippets


use Innmind\MediaType\MediaType;

$type = MediaType::of('application/json+some-extension; charset=utf-8');
$type->topLevel(); // application
$type->subType(); // json
$type->suffix(); // some-extension
$type->parameters()->first()->name(); // charset
$type->parameters()->first()->value(); // utf-8
$type->toString(); // application/json+some-extension; charset=utf-8