简体   繁体   English

如何绕过CodeIgniter中不允许的关键字符

[英]How to bypass Disallowed Key Characters in CodeIgniter

I have this problem in finding a solutions in Disallowed Key Characters in CodeIgniter. 在CodeIgniter的“不允许的关键字符”中找到解决方案时,我遇到了这个问题。 My problem is, I want that the £ sign will be passed in through my url. 我的问题是,我希望£符号会通过我的网址传递。

For example, 例如,

  • I have this product testing-product-nutella . 我有此产品testing-product-nutella
  • I want to add a £ sign besides testing-product-nutella£ somewhat like that. 除了testing-product-nutella£之外,我还想添加一个£符号。 here is my code below 这是我的下面的代码

//---------------------------------------------------------------------------------// //--------------------------> Build the product list data--------------------------// //---------------------------------------------------------------------------------// // ------------------------------------------------ --------------------------------- // // ------------- ------------->建立产品清单数据-------------------------- // //- -------------------------------------------------- ------------------------------ //

        $prod_list              = Array();

        foreach($prods_query as $prod)
        {
            //echo htmlentities($prod['prod_name']);
            //print_r($prod);

            //$prod_name_url        = Make_into_url($prod['prod_name']);
            $prod_name_url      = htmlentities($prod['prod_name']);
            print_r($prod_name_url);

            // get the minimum order quantity and price from db
            if ($min_price = $this->Price_model->Get_listing_price($prod['prod_id']))
            {
                $min_order_qty      = $min_price['qty_value'];
                $min_order_price    = $min_price['price_amount'] > 0 ? number_format($min_price['price_amount'], 2) : false;
            }
            else
            {
                // this shouldn't happen but just in case...
                $min_order_qty      = "";
                $min_order_price    = "";
            }

            // get the default image for the product from the database
            $default_pic_row        = $this->Picture_model->Get_default_product_picture($prod['prod_id']);

            // get a list of all the special categories that a product is in
            $product_spec_cats      = $this->Special_category_model->Get_product_special_cats($prod['prod_id']);

            // is the product on special offer, if so, get the details
            $product_spec_off       = $this->Special_offer_model->Get_product_special_offer_details($prod['prod_id']);



            $nameUrl = urlencode($prod_name_url);
            echo "<pre>";
            echo $nameUrl;
            echo "</pre>";

            $prod_list[]            = Array(
                                            "prod_id"           => $prod['prod_id']
                                            ,"prod_name"        => urldecode($nameUrl)
                                            ,"prod_min_price"   => $min_order_price
                                            ,"prod_min_qty"     => $min_order_qty
                                            ,"prod_desc"        => $prod['prod_desc']
                                            ,"prod_code"        => $prod['prod_code']
                                            ,"prod_pic_thumb"   => $default_pic_row['pic_thumb']
                                            ,"product_colours_image"    => ""
                                            ,"prod_spec_cats"   => $product_spec_cats
                                            ,"prod_spec_off"    => $product_spec_off
                                            );
        }

When I tried to add a £ sign it says Disallowed Key Characters. 当我尝试添加£符号时,显示“不允许的关键字符”。 I want that when I add a special characters and passed in the url the product will display by having the special characters. 我希望当我添加特殊字符并传递url时,产品将通过具有特殊字符来显示。

I tried to see the files in system/libraries/Input.php file and tried to change a lil bit on the code in function _clean_input_keys but it didnt work. 我试图查看system/libraries/Input.php文件中的文件,并尝试更改function _clean_input_keys代码的lil位,但是它没有起作用。 Can someone help me figured this thing out? 有人可以帮我解决这个问题吗? Any help is muchly appreciated. 非常感谢任何帮助。

TIA TIA

You have to url encode the pound sign. 您必须对英镑符号进行网址编码。 Build your url string and then pass it to the php urlencode($url) function which will convert it into allowed characters: "%a3" for a "£" 构建您的url字符串,然后将其传递给php urlencode($url)函数,该函数会将其转换为允许的字符:“%a3”表示“£”

To retrieve it use urldecode($url) 要检索它,请使用urldecode($url)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM