GBK coded PHP script causes syntax errors

Source: Internet
Author: User
Tags character set php script zend

This is because, in the GBK environment, "玕" code is "0xAB 0x5c, So, is a ' 5c ' problem."

In general, it is recommended that you use Unicode as a code file character set, if you want to use GBK, and then actively converted.

However, on the question, if your script has to GBK code, how can you avoid this problem?

Starting with PHP5.3, PHP introduced Zend multibyte to support multiple character set encoding. For the above code, we modify the following:

Then, in php.ini, configure:

mbstring.internal_encoding=cp936

or run PHP with the following command:

$php-dmbstring.internal_encoding=cp936 test.php

In this way, PHP will be cp936 encoding to execute the test.php. For more information on Zend multibyte, see: php:what is–enable-zend-multibyte Configure option for?, PHP declare



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.