php method to determine garbled characters: 1. Use regular matching to determine whether there are garbled characters in the string; 2. Use the "json_encode($string) === 'null'" method to determine if the string contains Garbled characters, the string will return null.
Recommended: "PHP Video Tutorial"
php determines whether a string contains garbled characters
Determine whether a string contains garbled characters:
1: You can use regular matching, but you need to know what symbols the garbled characters probably include.
2. Use black magic json_encode( $string) === 'null' to judge. If the string contains garbled characters, json_encode will return null.
The above is the detailed content of How to determine whether a string is garbled in php. For more information, please follow other related articles on the PHP Chinese website!