Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to intercept the first Chinese garbled code by php

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how php intercepts the first Chinese garbled code," the explanation content in the article is simple and clear, easy to learn and understand, please follow the ideas of Xiaobian slowly in-depth, together to study and learn "how php intercepts the first Chinese garbled code" bar!

php intercepts the first Chinese garbled code solution: 1, create a PHP sample file;2, set "charset= utf-8" encoding;3, by "function str($str ='',$len=0){...} "The method can be intercepted.

Operating environment: Windows 7, PHP 7.4, DELL G3

Php how to intercept the first Chinese garbled code?

php solves Chinese interception garbled code problem

in view of intercept that character string to appear Chinese garbled code question, on the net has many introduction, also has many functions, but the author looked at the net function, always felt that somewhat awkward,

So I wrote a function to prevent Chinese garbled characters from intercepting strings.

The principle of implementation is still relatively simple, mainly using ASCII encoding and Chinese encoding binary range is not consistent to distinguish them, and then, through substr() intercept string function to achieve.

Here is the code I wrote, note: I am only here for utf-8 coding, other coding, the viewer can manually change the function to support other coding.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report