Codeigniter 代码点火器::将url作为参数发送?

Codeigniter 代码点火器::将url作为参数发送?,codeigniter,Codeigniter,我正在创建一个ajax函数来编辑一些设置 这些必须通过url进行处理 i、 e url将是 这很好,但是。 其中一个设置是url 如何以这种方式传递此消息?查找URI类: 来自index.php/user/search/name/joe/location/UK/gender/male 你可以得到: [array] ( 'name' => 'joe' 'location' => 'UK' 'gender' => 'male' ) 使用: $arr

我正在创建一个ajax函数来编辑一些设置

这些必须通过url进行处理

i、 e

url将是

这很好,但是。 其中一个设置是url

如何以这种方式传递此消息?

查找URI类:

来自index.php/user/search/name/joe/location/UK/gender/male

你可以得到:

[array]
(
    'name' => 'joe'
    'location'  => 'UK'
    'gender'    => 'male'
)
使用:

$array = $this->uri->uri_to_assoc(3);
您还可以找到有用的$this->uri->segment\u数组。

查找uri类:

来自index.php/user/search/name/joe/location/UK/gender/male

你可以得到:

[array]
(
    'name' => 'joe'
    'location'  => 'UK'
    'gender'    => 'male'
)
使用:

$array = $this->uri->uri_to_assoc(3);
您还可以找到有用的$this->uri->segment\u数组。

这可能有用

$url = 'http://stackoverflow.com/questions/4245416/code-igniter-send-url-as-param';

$encoded = base64_encode($url);
//aHR0cDovL3N0YWNrb3ZlcmZsb3cuY29tL3F1ZXN0aW9ucy80MjQ1NDE2L2NvZGUtaWduaXRlci1zZW5kLXVybC1hcy1wYXJhbQ==

// Make your URL
$my_url = "site.com/controller/method/params/params/" . $encoded;

// redirect or whatever

$encoded_url = $this->uri->segment(4); // (or wherever the URL is)

$url = base64_decode($encoded_url);
// http://stackoverflow.com/questions/4245416/code-igniter-send-url-as-param
这可能有用

$url = 'http://stackoverflow.com/questions/4245416/code-igniter-send-url-as-param';

$encoded = base64_encode($url);
//aHR0cDovL3N0YWNrb3ZlcmZsb3cuY29tL3F1ZXN0aW9ucy80MjQ1NDE2L2NvZGUtaWduaXRlci1zZW5kLXVybC1hcy1wYXJhbQ==

// Make your URL
$my_url = "site.com/controller/method/params/params/" . $encoded;

// redirect or whatever

$encoded_url = $this->uri->segment(4); // (or wherever the URL is)

$url = base64_decode($encoded_url);
// http://stackoverflow.com/questions/4245416/code-igniter-send-url-as-param

我知道这一点。但是,其中一个参数让我们假设location是一个网站location是一个url,您最终会看到`index.php/user/search/name/joe/location/`我相信您可以看到这里的问题……尝试使用segment_数组,如果类似于/ajax/setting1/setting2,您可以忽略第一个值。它会起作用的,这不是问题所在。问题是,url中的字符正在破坏它。我知道这一点。但是,其中一个参数让我们假设location是一个网站location是一个url,您最终会看到`index.php/user/search/name/joe/location/`我相信您可以看到这里的问题……尝试使用segment_数组,如果类似于/ajax/setting1/setting2,您可以忽略第一个值。它会起作用的,这不是问题所在。问题是,URL中的字符正在破坏它。您应该考虑将Ajax调用转换为POST请求而不是GET请求。在大多数AJAX工具包中,这是很简单的。您应该考虑将Ajax调用转换为POST请求而不是GET请求。这在大多数AJAX工具包中都很简单。这是我知道的唯一方法。但当然最好切换到POST请求。这是我知道的唯一方法。但当然最好切换到POST请求。