diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2014-02-24 15:50:10 +0100 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2014-02-24 15:50:10 +0100 |
commit | 7afac85d56973c3851e10761ba278b1805aab565 (patch) | |
tree | 26584fdf09fd9bde24b99ebab5561f39d21182ac | |
parent | 23cf49aa87c1294c18e2c9c4529bcc107cb87415 (diff) | |
download | Mime-7afac85d56973c3851e10761ba278b1805aab565.zip Mime-7afac85d56973c3851e10761ba278b1805aab565.tar.gz Mime-7afac85d56973c3851e10761ba278b1805aab565.tar.bz2 |
Add syntax highlighting.
-rw-r--r-- | README.md | 80 |
1 files changed, 43 insertions, 37 deletions
@@ -19,29 +19,33 @@ All we need is static methods `Hoa\Mime\Mime::getExtensionsFromMime` to get extensions from a type and `Hoa\Mime\Mime::getMimeFromExtension` to get type from an extension: - print_r(Hoa\Mime\Mime::getExtensionsFromMime('text/html')); - - /** - * Will output: - * Array - * ( - * [0] => html - * [1] => htm - * ) - */ - - var_dump(Hoa\Mime\Mime::getMimeFromExtension('webm')); - - /** - * Will output: - * string(10) "video/webm" - */ +```php +print_r(Hoa\Mime\Mime::getExtensionsFromMime('text/html')); + +/** + * Will output: + * Array + * ( + * [0] => html + * [1] => htm + * ) + */ + +var_dump(Hoa\Mime\Mime::getMimeFromExtension('webm')); + +/** + * Will output: + * string(10) "video/webm" + */ +``` By default, `Hoa\Mime\Mime` uses the `hoa://Library/Mime/Mime.types` file as database. We can change this behavior by calling the `Hoa\Mime\Mime::compute` before any computations: - Hoa\Mime\Mime::compute('/etc/mime.types'); +```php +Hoa\Mime\Mime::compute('/etc/mime.types'); +``` ### Stream-related informations @@ -49,25 +53,27 @@ By instanciating the `Hoa\Mime\Mime` class with a stream, we are able to get some informations about the stream, such as its extension, others extensions, type, etc. Thus: - $type = new Hoa\Mime\Mime(new Hoa\File\Read('index.html')); - - var_dump( - $type->getExtension(), - $type->getOtherExtensions(), - $type->getMime(), - $type->isExperimental() - ); - - /** - * Will output: - * string(4) "html" - * array(1) { - * [0]=> - * string(3) "htm" - * } - * string(9) "text/html" - * bool(false) - */ +```php +$type = new Hoa\Mime\Mime(new Hoa\File\Read('index.html')); + +var_dump( + $type->getExtension(), + $type->getOtherExtensions(), + $type->getMime(), + $type->isExperimental() +); + +/** + * Will output: + * string(4) "html" + * array(1) { + * [0]=> + * string(3) "htm" + * } + * string(9) "text/html" + * bool(false) + */ +``` ## Documentation |