PHP – mb_preferred_mime_name() function

PHPServer Side ProgrammingProgramming

The mb_preferred_mime_name() function in PHP is used to return the MIME string for the character encoding and it returns the charset string. It gets a MIME (Multipurpose Internet Mail Extensions) charset string for the specific encoding.

Syntax

string mb_preferred_mime_name($string_encoding)

Parameters

mb_preferred_mime_name() accepts only one parameter −

  • $string_encoding − This parameter is used to check the encoding.

Return Values

The mb_preferred_mime_name() function returns the MIME charset string for the charset encoding. It returns False if no charset is preferred for the given encoding.

Example

Let us now take an example and see how it works −

<?php
   // Encoding
   $string_encoding = "EUC-JP";
   mb_http_output($string_encoding);

   // output control function is used
   ob_start("mb_output_handler");
   header(mb_preferred_mime_name($string_encoding));
   print_r($string_encoding);
?>

Output

It will produce the following output −

EUC-JP
raja
Published on 11-Oct-2021 13:26:57
Advertisements