Codeigniter shopping cart class cannot add Chinese solutions, codeigniter car class _ PHP Tutorial

Source: Internet
Author: User
Tags php regular expression
Codeigniter cannot add Chinese characters to the shopping cart class. Codeigniter cannot add Chinese characters to the shopping cart class. This document describes how to add Chinese characters to the shopping cart class of codeigniter. For example, Codeigniter cannot add Chinese characters to a shopping cart.

This example describes how to add Chinese characters to the Codeigniter shopping cart class. 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.

Examples in this article describes how to add Chinese characters to the Codeigniter shopping cart class. I will share it with you for your reference...

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.