Exemplo n.º 1
0
            $instance->mime_types[$alias_ext] = $mime_type;
        }
    }
    static function extension_by_mime_type($mime_type = "text/html")
    {
        $instance = self::getInstance();
        $extension = array_search($mime_type, $instance->mime_types);
        if ($extension === false) {
            throw new MimeTypeException("MimeType Not Found: {$mime_type}");
        }
        return $extension;
    }
    static function lookup_by_extension($extension = "html")
    {
        $instance = self::getInstance();
        if (array_key_exists($extension, $instance->mime_types)) {
            return $instance->mime_types[$extension];
        }
        return false;
    }
}
class MimeTypeException extends Exception
{
}
MimeType::register("text/html", "html", array("htm"));
MimeType::register("text/json", "json");
MimeType::register("text/javascript", "js");
MimeType::register("text/css", "css");
MimeType::register("text/plain", "text");
MimeType::register("text/plain", "txt");