Skip to content

Commit

Permalink
example how to use custom magic database
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiske committed Sep 4, 2011
1 parent 70010d6 commit 533fe6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/examples/custom-magic.magic
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
0 search/1/c =<?php PHP script text
!:mime text/x-custom-mimetype
14 changes: 14 additions & 0 deletions docs/examples/custom-magic.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* Demonstrates how to use a custom magic database.
* The detected MIME type should be text/x-custom-mimetype
*/
require_once 'MIME/Type.php';
$mt = new MIME_Type();
$mt->magicFile = dirname(__FILE__) . '/custom-magic.magic';

$type = $mt->autoDetect(dirname(__FILE__) . '/custom-magic.php');
echo 'Type: ' . $type . "\n";
echo 'Media: ' . $mt->media . "\n";
echo 'Subtype: ' . $mt->subType . "\n";
?>

0 comments on commit 533fe6d

Please sign in to comment.