How to determine whether a string is garbled in php

藏色散人
Release: 2023-03-05 11:12:02
Original
4083 people have browsed it

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!