String-About PHP string encoding problems

Source: Internet
Author: User
$str = ' finger solid '; echo str_replace (' belly ', ' big ', $str);

The page is GBK encoded, so you can actually replace it.

Checked the respective codes.

means: d6b8: b9cc Belly: b8b9

Finger-Solid: D6b8b9CC
Abdomen: b8b9

What is the best way to replace an error?

Reply content:

$str = ' finger solid '; echo str_replace (' belly ', ' big ', $str);

The page is GBK encoded, so you can actually replace it.

Checked the respective codes.

means: d6b8: b9cc Belly: b8b9

Finger-Solid: D6b8b9CC
Abdomen: b8b9

What is the best way to replace an error?

The most straightforward function is mb_ereg_replace you can use it improperly.

Or you can use the MB_SUBSTR/ICONV_SUBSTR and Mb_strpos/iconv_strpos in the Iconv/mbstring library to write a mb_str_replace/iconv_str_ for multibyte encoding. Replace.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.