Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
PHP – Get the internal settings of mbstring with mb_get_info()
The mb_get_info() function in PHP is used to get the internal settings of mbstring extension. This function is supported in PHP 5.4 or higher version and is essential for debugging and understanding current multibyte string configurations.
Syntax
array|string|int mb_get_info(string $type = "all")
Parameters
It accepts only a single parameter to get the multibyte information.
$type − If the type parameter is not specified or it is specified as "all", then it will return all available mbstring settings. If a specific type is provided, it returns only that setting value.
Available type values include ?
"internal_encoding", "http_input", "http_output", "http_output_conv_mimetypes", "mail_charset", "mail_header_encoding", "mail_body_encoding", "illegal_chars", "encoding_translation", "language", "detect_order", "substitute_character", "strict_detection"
Return Value
mb_get_info() returns an array of all type information if the type is not specified, otherwise it returns a specific type value as string or integer. It returns false on failure.
Note: From PHP 8.0.0, the types "func_overload" and "func_overload_list" are not supported.
Example 1: Get All Settings
<?php
$settings = mb_get_info();
print_r($settings);
?>
Array
(
[internal_encoding] => UTF-8
[http_output] => UTF-8
[http_output_conv_mimetypes] => ^(text/|application/xhtml\+xml)
[mail_charset] => UTF-8
[mail_header_encoding] => BASE64
[mail_body_encoding] => BASE64
[illegal_chars] => 0
[encoding_translation] => Off
[language] => neutral
[detect_order] => Array
(
[0] => ASCII
[1] => UTF-8
)
[substitute_character] => 63
[strict_detection] => Off
)
Example 2: Get Specific Setting
<?php
echo "Internal Encoding: " . mb_get_info('internal_encoding') . "<br>";
echo "Language: " . mb_get_info('language') . "<br>";
echo "Illegal Characters: " . mb_get_info('illegal_chars') . "<br>";
?>
Internal Encoding: UTF-8 Language: neutral Illegal Characters: 0
Conclusion
The mb_get_info() function is valuable for inspecting mbstring configuration settings. Use it without parameters to get all settings or specify a type parameter to retrieve specific configuration values for debugging multibyte string operations.
