Home  >  Article  >  Backend Development  >  How to determine whether a string is garbled in php

How to determine whether a string is garbled in php

藏色散人
藏色散人Original
2020-08-28 09:47:313956browse

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.

How to determine whether a string is garbled in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn