Home >Backend Development >PHP Tutorial >utf8_encode() and utf8_decode function_PHP tutorial

utf8_encode() and utf8_decode function_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:54:182158browse

utf8_encode() function encodes an iso-8859-1 string into utf-8.

utf8_encode(string);
*/
$str="Hello, world!"; //Define string
$result=utf8_decode($str); //Convert encoding
echo $result; //Output the conversion result


//Example 2

/*
The utf8_decode() function decodes a utf-8 string into iso-8859-1.

This function converts an iso-8859-1 string encoded in utf-8 into a single-byte iso-8859-1 string.

If successful, this function returns the decoded string; otherwise it returns false.

utf8_decode(string)

*/

$str="hello world!"; //Define string
$result=utf8_decode($str); //Convert encoding
echo $result;
$result=utf8_encode($result); //Convert encoding
echo $result; //Output the conversion result
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632343.htmlTechArticleutf8_encode() function encodes the iso-8859-1 string into utf-8. utf8_encode(string); */ $str=Hello, world! ;//Define string $result=utf8_decode($str);//Convert encoding echo...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn