PHP code example of axy / mime

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

    

axy / mime example snippets


use axy\mime\MimeType;

$type = 'image/png';
$pattern = 'image/*';

MimeType::match($type, $pattern); // TRUE

use axy\mime\MimeType;

$type = new MimeType('Image/PNG');

echo $type->getMimeType(); // image/png
echo $type->getType(); // image
echo $type->getSubtype(); // png
echo $type->isType('image'); // TRUE
echo $type->isType(MimeType::AUDIO); // FALSE

$type = new MimeType('image/png');

$type->match('image/jpeg'); // FALSE
$type->match('image/*); // TRUE

$type('image/png'); // __invoke()

$type($instanceOfMimePattern); // see MimePattern

use axy\mime\MimePattern;

$pattern = new MimePattern('IMAGE/*');

$pattern->getPattern(); // image/*

$pattern->match('image/png'); // TRUE
$pattern('image/jpeg'); // __invoke
$pattern($instanceOfMimeType);