Current Location: Home> Function Categories> mb_preferred_mime_name

mb_preferred_mime_name

Get the MIME character set string
Name:mb_preferred_mime_name
Category:Multi-byte string
Programming Language:php
One-line Description:Returns the MIME name of the specified character set

Function name: mb_preferred_mime_name()

Function Description: The mb_preferred_mime_name() function returns the MIME name of the specified character set.

Applicable version: PHP 7.2.0 or higher

Usage: string mb_preferred_mime_name ( string $encoding )

parameter:

  • encoding: To get the character set encoding of the MIME name. Common encodings include "UTF-8", "ISO-8859-1", etc.

Return value: Returns the MIME name of the specified character set, and if the corresponding MIME name is not found, it returns FALSE.

Example:

 $charset = "UTF-8"; $mimeName = mb_preferred_mime_name($charset); if ($mimeName !== false) { echo "MIME 名称:".$mimeName; } else { echo "未找到对应的MIME 名称"; }

The output results of the above example are:

 MIME 名称:UTF-8

Notes:

  • The mb_preferred_mime_name() function depends on the mbstring extension, so you need to make sure that the extension is enabled before using the function.
  • If the specified character set encoding cannot find the corresponding MIME name, the function returns FALSE.
  • This function is mainly used to obtain the MIME name corresponding to the character set encoding, which is convenient for use in scenarios such as generating HTTP header information or processing file uploads.
Similar Functions
Popular Articles