我在CodeIgniter中的Disallowed Key Characters中找到解决方案时遇到了这个问题。我的问题是,我希望£
符号将通过我的网址传递。
例如,
testing-product-nutella
。 £
之外添加一个testing-product-nutella£
符号。
这是我的代码// --------------------------------------------- ------------------------------------ // // -------------------------->构建产品列表数据-------------------------- // // ------------------------------------------------ --------------------------------- //
$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
);
}
当我尝试添加£
符号时,它会显示“禁止关键字符”。我希望当我添加一个特殊字符并传入url时,产品将通过特殊字符显示。
我试图查看system/libraries/Input.php
文件中的文件并尝试更改function _clean_input_keys
中代码的lil位,但它没有用。有人能帮我解决这个问题吗?任何帮助都非常感谢。
TIA
答案 0 :(得分:0)
你必须对英镑符号进行url编码。构建你的url字符串,然后将其传递给php urlencode($url)
函数,该函数将其转换为允许的字符:“%a3”表示“£”
要检索它,请使用urldecode($url)