PHP code example of mvccore / ext-tool-mimetype-extension

1. Go to this page and download the library: Download mvccore/ext-tool-mimetype-extension 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/ */

    

mvccore / ext-tool-mimetype-extension example snippets


use \MvcCore\Ext\Tools;

$mimeTypes = Tools\MimeTypesExtensions::GetMimeTypesByExtension('dmg');
// ['application/x-apple-diskimage', 'application/octet-stream']
var_dump($mimeTypes);

$mimeTypes = Tools\MimeTypesExtensions::GetMimeTypesByExtension('madness');
// NULL - means no data for given extension
var_dump($mimeTypes);

$extensions = Tools\MimeTypesExtensions::GetExtensionsByMimeType('application/msword');
// ['doc','dot'] - means mimetype `application/msword` could have two different extensions
var_dump($extensions);

$extensions = Tools\MimeTypesExtensions::GetExtensionsByMimeType('video/bmpeg');
// [''] - means file type is defined as file always without any extension
var_dump($extensions);

$extensions = Tools\MimeTypesExtensions::GetExtensionsByMimeType('something/crazy');
// NULL - means no data for given mimetype
var_dump($extensions);