Look at the code:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> New Document </title>
<meta name= "Author" content= ""/>
<meta name= "keywords" content= ""/>
<meta name= "description" content= ""/>
<link rel= "stylesheet" type= "Text/css" href= ""/>
<body>
<?php
$string 1 = "I am a phper";
$string 2 = "This website is a cloud-dwelling community";
Print_r (Str_split ($string 1));
echo "<br/>";
Print_r (Str_split ($string 2,4));
?>
</body>
The test results are what I expected--
Chinese garbled
Why? Why? Why? Why? What is garbled? Explain to me, what, is%& garbled!
Because English is not garbled, only Chinese garbled, first thought of the coding problem, then suddenly remembered to UTF-8 code is UTF-8 need 3 bytes, dead Horse when live horse medicine!
So Print_r (Str_split ($string 2,4)), 4 of this sentence, was replaced by 6, so--see the results
Also, you can try to change the encoded charset UTF-8 to GB2312, because Unicode encoding requires 2 bytes, so Gb2312 coding can save 1/3 more space than UTF-8, but if you want to be compatible with traditional Chinese, Korean, Other languages in Japanese need to use UTF-8.