PHP mb_detect_encoding() Function Last Updated : 26 Apr, 2023 Comments Improve Suggest changes Like Article Like Report The mb_detect_encoding() is an inbuilt function in PHP that is used to detect the encoding of the string. Syntax: string|false mb_detect_encoding( string $string, array|string|null $encodings = null, bool $strict = false ) Parameters: This function accepts three parameters that are described below. $string: The string for which the encoding needs to be detected.$encoding: A comma-separated list of encodings to be checked. If not specified, a list of popular encodings is used.$strict: A boolean value indicating whether to use strict detection or not. If set to "true", only encodings that are super-sets of the input string's encoding are returned. Return Values: This function returns detecting encoding of the input string, if no encoded is detected, it will return "false". Example 1: The following program demonstrates the mb_detect_encoding() function. PHP <?php $string = "Hello world!"; $encoding = mb_detect_encoding($string); echo "The string '$string' is encoded in '$encoding'."; ?> Output: The string 'Hello world!' is encoded in 'ASCII'. Example 2: The following program demonstrates the mb_detect_encoding() function. PHP <?php $string = "This is an English sentence."; $encoding = mb_detect_encoding($string); if ($encoding === 'UTF-8') { echo "The string '$string' is encoded in UTF-8."; } else { echo "The string '$string' is not encoded in UTF-8."; } ?> Output: The string 'This is an English sentence.' is not encoded in UTF-8. Reference: https://www.php.net/manual/en/function.mb-detect-encoding.php Comment More infoAdvertise with us Next Article PHP mb_detect_encoding() Function neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Multibyte-String Similar Reads PHP mb_check_encoding() Function The mb_check_encoding() function is an inbuilt function in PHP that is used to check whether a given string is valid for specified encoding or not. Syntax: bool mb_check_encoding( array|string|null $value = null, string $encoding = null ) Parameters: This function accepts two parameters that are des 2 min read PHP mb_convert_encoding() Function The mb_convert_encoding() function is an inbuilt function in PHP that transforms the string into another character encoding. Syntax: mb_convert_encoding( array|string $string, string $to_encoding, array|string|null $from_encoding = null ): array|string|falseParameters: This function has 3 parameters 1 min read PHP mb_encoding_aliases() Function The mb_encoding_aliases() is an inbuilt PHP function that can be utilized to retrieve aliases for a known encoding type. Syntax: mb_encoding_aliases(string $encoding): array Parameter: This function has only one parameter: encoding: This parameter specifies the encoding type that is to be checked fo 1 min read PHP mb_detect_order() Function The mb_detect_order() function is an inbuilt function in PHP that is utilized to set or get the character encoding detection order. Syntax: mb_detect_order(array|string|null $encoding = null): array|bool Parameters: Â This function has only one parameter. encoding: This parameter returns the current 1 min read PHP | iconv_get_encoding() Function The iconv_get_encoding() function is an inbuilt function in PHP which is used to retrieve the internal configuration variables of iconv extension. Syntax: mixed iconv_get_encoding( $type = "all" ) Parameters: This function accepts single parameter $type. The value of $type parameter are: all input_e 1 min read PHP | base64_encode() Function The base64_encode() function is an inbuilt function in PHP that is used to encode data with MIME base64. MIME (Multipurpose Internet Mail Extensions) base64 is used to encode the string in base64. The base64_encoded data takes 33% more space than the original data. Syntax: string base64_encode( $dat 1 min read PHP mb_chr() Function The mb_chr() function is an inbuilt function in PHP that is used to return the character unicode point value that is encoded into the specified encoding. Syntax: string|false mb_chr(int $codepoint, string $encoding = null) Parameters: This function accepts two parameters that are described below: $c 1 min read PHP | base64_decode() Function The base64_decode() is an inbuilt function in PHP which is used to Decodes data which is encoded in MIME base64.Syntax: string base64_decode( $data, $strict ) Parameters: This function accepts two parameter as mentioned above and described below: $data: It is mandatory parameter which contains the e 1 min read PHP mb_decode_mimeheader() Function The mb_decode_mimeheader() function is an inbuilt function in PHP where the string is decoded into the MIME header field. Syntax: mb_decode_mimeheader(string $string): string Parameter: This function has a single parameter: string: This parameter specifies the string that is to be decoded. Return Va 1 min read PHP mb_ereg_search() Function The mb_ereg_search() is a PHP function used to search & match for a regular expression pattern in a string using multi-byte characters. It is similar to preg_match() but works with multi-byte characters. Syntax: mb_ereg_search(?string $pattern = null, ?string $options = null): boolParameters: Th 2 min read Like