为什么codeigniter购物车类不允许在名称中使用任何特殊字符? [英] Why codeigniter shopping cart class doesn't allow any special character in the name?

查看:121
本文介绍了为什么codeigniter购物车类不允许在名称中使用任何特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题就像在标题 - 为什么codeigniter购物车类不允许任何特殊字符的名称?当我添加一些项目的正常名称只包含标准字符,它的工作原理就像魅力。但是,如果我添加类似的东西,说,字/字或类似的东西,它不会添加任何东西到购物车。

I have a question just like in the title - Why codeigniter shopping cart class doesn't allow any special character in the name? When I'm adding some item with normal name containing only standard characters it works like charm. However if I add something like, say, "word / word" or something like that it won't add anything to the shopping cart. Can someone provide me with some hints on that one please?

推荐答案

如果您查看 Cart.php 您将在第31行看到 var $ product_name_rules ='\.\:\-_ a-z0-9';

If you look on Cart.php you will see on line 31 var $product_name_rules = '\.\:\-_ a-z0-9';.

更改此变量的好方法是使用此代码将MY_Cart.php放在您的应用程序\libraries\MY_Cart.php上:

A nice way to change this variable is putting a MY_Cart.php on your application\libraries\MY_Cart.php with this code:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Cart extends CI_Cart {

    var $product_name_rules = '[:print:]';

}

或者您也可以在添加产品时修改它,使用:

Or you can also modify it when you add the product, using:

$this->cart->product_name_rules = '[:print:]';
$this->cart->insert(array());

这篇关于为什么codeigniter购物车类不允许在名称中使用任何特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆