substr cutting Chinese characters problem
Cutting is one of the characters using substr very common PHP syntax
But it
Because in the next UTF-8 encoding,
Text in a word for three yuan group, so cut the first four yuan Group will print error code characters

So now tell you
This function
This function can be used to specify the encoding string
And so
Specify four words is four characters Oh
I hope people are looking at this article helpful
The following examples are listed

echo substr("大家好",0,4);
echo "
"; echo mb_substr("大家好",0,4,"UTF-8");