Codeigniter shopping cart class does not support adding Chinese characters _ php instance

Source: Internet
Author: User
Tags php regular expression codeigniter
This article mainly introduces how to add Chinese characters to the Codeigniter shopping cart class, which involves the restriction on Chinese characters in the underlying code. You can modify the regular expression matching rules to solve the problem, for more information about how to add Chinese characters to the Codeigniter shopping cart class, see the example in this article. Share it with you for your reference. The specific analysis is as follows:

Some may find that the Codeigniter shopping cart class cannot add Chinese characters. After I have been searching for N for a long time, I found that the following code restricted the input of Chinese characters and modified systemlibrariesCart. php: comment out the product name judgment in line 186-190. The Code is as follows:

The Code is as follows:

If (! Preg_match ("/^ [". $ this-> product_name_rules. "] + $/I", $ items ['name'])
{
Log_message ('error', 'an invalid name was submitted as the product name :'. $ items ['name']. 'The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces ');
Return FALSE;
}


However, deleting a regular expression is not the best solution. You can simply change the regular expression matching to Chinese. If you are interested, you can refer to the PHP regular expression to verify Chinese.

I hope this article will help you with ThinkPHP framework programming.

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.