Home php教程 php手册 Codeigniter购物车类不能添加中文的解决方法

Codeigniter购物车类不能添加中文的解决方法

Jun 06, 2016 pm 08:16 PM
codeigniter cannot Solution

这篇文章主要介绍了Codeigniter购物车类不能添加中文的解决方法,涉及底层代码中关于中文的限制问题,可通过修改正则匹配规则来解决,需要的朋友可以参考下

本文实例讲述了Codeigniter购物车类不能添加中文的解决方法。分享给大家供大家参考。具体分析如下:

有朋友可能会发现Codeigniter 购物车类不能添加中文,我找了N久才发现下面一段代码限制了输入中文了,修改systemlibrariesCart.php,注释第186-190行产品名称的判断,代码如下:

复制代码 代码如下:

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; 
}


不过删除不是最好的办法,我们可以直接把正则匹配改成中文就行了。感兴趣的朋友可以参考这篇《PHP 正则表达式验证中文的问题》。

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Printer operation cannot be completed error 0x0000709 Solution Printer operation cannot be completed error 0x0000709 Solution Apr 20, 2024 pm 10:10 PM

Printer operation cannot be completed error 0x0000709 Solution

Methods to solve the problem of Chinese garbled characters in PHP Dompdf Methods to solve the problem of Chinese garbled characters in PHP Dompdf Mar 05, 2024 pm 03:45 PM

Methods to solve the problem of Chinese garbled characters in PHP Dompdf

Solution: Socket Error when handling HTTP requests Solution: Socket Error when handling HTTP requests Feb 25, 2024 pm 09:24 PM

Solution: Socket Error when handling HTTP requests

What should I do if my Black Shark phone continues to cycle on and off? The solution is revealed! What should I do if my Black Shark phone continues to cycle on and off? The solution is revealed! Mar 25, 2024 am 09:36 AM

What should I do if my Black Shark phone continues to cycle on and off? The solution is revealed!

Linux Oops Revealed: Causes of Errors and Solutions Linux Oops Revealed: Causes of Errors and Solutions Mar 20, 2024 am 11:15 AM

Linux Oops Revealed: Causes of Errors and Solutions

How to solve the Linux error 'No route to host' How to solve the Linux error 'No route to host' Feb 26, 2024 pm 12:24 PM

How to solve the Linux error 'No route to host'

What does error code 678 mean and how to solve it What does error code 678 mean and how to solve it Feb 29, 2024 am 10:28 AM

What does error code 678 mean and how to solve it

Deepseek official website entrance access guide Solve the common problems that cannot be logged in Deepseek official website entrance access guide Solve the common problems that cannot be logged in Feb 19, 2025 pm 04:30 PM

Deepseek official website entrance access guide Solve the common problems that cannot be logged in

See all articles