CodeIgnitor urlencode / decode

编程入门 行业动态 更新时间:2024-10-21 15:41:56
本文介绍了CodeIgnitor urlencode / decode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Controller

function delete_payment($payment_id) { $this->sale_lib->delete_payment($payment_id); $this->_reload(); }

查看

<?php echo anchor("sales/delete_payment/$payment_id",'['.$this->lang->line('common_delete').']');?>

$ payment_id可能类似礼品卡:1或礼品卡: 12345983984334

It is possible for $payment_id to be something like "Gift Card:1" or "Gift Card:12345983984334"

当它是礼品卡:1时,网址会自动解码,删除功能工作,当它是一个较长的字符串,如礼品卡:12345983984334不会解码。

When it is Gift Card:1 the url is automatically decoded and the delete function works, when it is a longer string such as Gift Card:12345983984334" the url is NOT decoded.

URLS是:

http://localhost/index.php/sales/delete_payment/Gift%20Card:1

http://localhost/index.php/sales/deletepayment / Gift%20Card:12345983984334

第一个不起作用,第二个不起作用

First one works, second one doesn't

推荐答案

实际上,我只是试图在我的本地机器(WAMP在Windows 7)复制你的情况,你是对的我试图在所有主要的浏览器(FF4,IE9,Chrome)差异。

Actually, I just tried to replicate your situation on my local machine (WAMP on Windows 7) and you're right. I tried on all major browsers (FF4,IE9,Chrome) and saw no differences.

虽然这不能真正回答你的问题,你可以使用php函数 rawurldecode :

Although this doesn't really answers your question, you can always rig a workaround like this with php function rawurldecode:

function delete_payment($payment_id) { $decoded_id = rawurldecode($payment_id); $this->sale_lib->delete_payment($decoded_id); $this->_reload(); }

这样,你的'id' c $ c>礼品卡:123456789 (我试过不同的lenghts和alwyas工作),准备好您的模型。

In this way you'll have your 'id' in the form Gift Card:123456789 (I tried with different lenghts and alwyas worked), ready for your model.

更多推荐

CodeIgnitor urlencode / decode

本文发布于:2023-10-27 11:18:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533213.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CodeIgnitor   urlencode   decode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!