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, see the CI framework.
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.