php框架

 首页 > php框架 > Codeigniter购物车类不能添加中文的解决方法

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

分享到:
【字体:
导读:
          本文实例讲述了Codeigniter购物车类不能添加中文的解决方法。分享给大家供大家参考。具体分析如下: 有朋友可能会发现Codeigniter 购物车类不能添加中文,我找了N久才发现下面一段代码...

本文实例讲述了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框架程序设计有所帮助。

分享到:
CI怎么引入公共的头部或者尾部文件?
CI怎么引入公共的头部或者尾部文件? 比如 header.html footer.html 在视图文件中 $this->load->view('header'); 这是其中一种方式,我喜欢这种方式。 或者,可以在 http://search.codeigniter.org.cn 上搜索 Layout 另一种是在控制器中把 $this->load->view('header') 赋给一个变量然后在view中...
CodeIgniter框架备份数据库
导出txt格式: // Load the DB utility class $this->load->dbutil();    // Backup your entire database and assign it to a variable $backup=&$this->dbutil->backup(array('format'=>'txt'));     // Load the file helper and write the file to your server ...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……