Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<mb_parse_strmb_regex_encoding>
^Multibyte String FunctionsLast updated: Mon, 26 Oct 2026

mb_preferred_mime_name

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_preferred_mime_name — Get MIME charset string

Description

function mb_preferred_mime_name(string $encoding): string|false

Get a MIME charset string for a specific encoding.

Parameters

encoding

The encoding being checked.

Return Values

The MIME charset string for character encoding encoding, or false if no charset is preferred for the given encoding.

Errors/Exceptions

As of PHP 8.0.0, a ValueError is thrown if encoding is an invalid encoding. Prior to PHP 8.0.0, an E_WARNING was emitted instead.

Changelog

Version Description
8.0.0 Now throws a ValueError if encoding is an invalid encoding. Previously, an E_WARNING was emitted and false was returned.

Examples

Example #1 mb_preferred_mime_name() example

<?php
$outputenc = "sjis-win";
mb_http_output($outputenc);
ob_start("mb_output_handler");
header("Content-Type: text/html; charset=" . mb_preferred_mime_name($outputenc));
?>


<mb_parse_strmb_regex_encoding>
^Multibyte String FunctionsLast updated: Mon, 26 Oct 2026