What are the best practices for handling MIME types in PHP when mime_content_type() is not available on the server?
When mime_content_type() is not available on the server, you can use finfo_open() and finfo_file() functions to handle MIME types in PHP. These functions allow you to create a file info resource and determine the MIME type of a file by passing its path.
// Create a file info resource
$finfo = finfo_open(FILEINFO_MIME_TYPE);
// Get the MIME type of a file
$mime_type = finfo_file($finfo, 'path/to/file');
// Close the file info resource
finfo_close($finfo);
// Output the MIME type
echo $mime_type;