Websites often submit garbled user names. How can I use PHP to determine whether the text contains garbled characters? {Code...} websites often submit garbled user names. How can I use PHP to identify whether the text contains garbled characters?
php
# UTF-8 $ str = 'accreditation '; preg_match_all ('/(...)/', $ str, $ matches); print_r ($ matches); die;
Array ([0] => Array ([0] => do [1] => [2] => Certificate) [1] => Array ([0] => Office [1] => [2] => Certificate ))
Reply content:
Websites often submit garbled user names. How can I use PHP to determine whether the text contains garbled characters?
php
# UTF-8 $ str = 'accreditation '; preg_match_all ('/(...)/', $ str, $ matches); print_r ($ matches); die;
Array ([0] => Array ([0] => do [1] => [2] => Certificate) [1] => Array ([0] => Office [1] => [2] => Certificate ))
This is caused by inconsistent front-end and back-end encoding. When the front-end inputs, you should determine whether to allow users to enter invalid characters.
The following is a supplement:
php
The three characters are encoded\u529e\ue708\u8bc1
It's UTF-8. I don't know how to do this.
First, the front-end should judge and process illegal characters when entering them, so as to avoid Garbled text. Second, the front-end and back-end codes should be consistent to avoid Garbled text.