Permalink
Browse files

example how to use custom magic database

  • Loading branch information...
1 parent 70010d6 commit 533fe6dfe1c8f3e32adcd8100bec68d1a85a0bd8 @cweiske cweiske committed Sep 4, 2011
Showing with 16 additions and 0 deletions.
  1. +2 −0 docs/examples/custom-magic.magic
  2. +14 −0 docs/examples/custom-magic.php
View
2 docs/examples/custom-magic.magic
@@ -0,0 +1,2 @@
+0 search/1/c =<?php PHP script text
+!:mime text/x-custom-mimetype
View
14 docs/examples/custom-magic.php
@@ -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.