How to convert variable (text/string) to utf8mb4 in php
问题 Hi I'm looking for a encode function for utf8mb4, $var = = "نور"; echo utf8mb4_encode($string); output = نور // its $var output in UTFMB4 The output should be "نور" this, its a conversion of $var in utfmb4 回答1: The return value of the mb_convert_encoding function could give you the desired result. $string = "نور"; $result = mb_convert_encoding($string, 'UTF-8', 'Windows-1252'); //$result = mb_convert_encoding($string, 'UTF-8', 'Windows-1254'); echo $result; 回答2: mb_convert_encoding is