MimeType::isValid( string $mimeType ): bool

In this article

Checks if a MIME type string is valid.

Parameters

$mimeTypestringrequired
The MIME type to validate.

Return

bool True if valid.

Source

public static function isValid(string $mimeType): bool
{
    // Basic MIME type validation: type/subtype
    return (bool) preg_match('/^[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*$/', $mimeType);
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.