substr与日语字符问题

Moh*_*fey 10 php utf-8 character-encoding

我很好地回应日语字符,但是当我尝试将字符串中的部分字符串消除时,它只是转向问号

注意:我将标题设置为utf-8

header('Content-Type: text/html; charset=utf-8');
Run Code Online (Sandbox Code Playgroud)

并做了元 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

$word = "????";
echo $word;       //works just fine

echo substr($word,-1);    //now it just echoes ?

//this one also failed
echo $word[0];    //echoes ?
Run Code Online (Sandbox Code Playgroud)

Mic*_*son 9

使用多字节字符串时multibyte string,在这种情况下,您需要使用这些函数mb_substr.

  • 我将竭尽全力,找到原谅和忘记的力量。 (3认同)