code igniter :: send url as param?

﹥>﹥吖頭↗ 提交于 2019-12-24 10:01:39

问题


I am creating an ajax function to edit some settings.

these must be handled via the url

(i.e)

the url would be http://example.com/setting1/setting2/setting3

This works fine but. One of the settings is a url.

How could I pass this in this way?


回答1:


this might work

$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



回答2:


Look for the URI Class: http://codeigniter.com/user_guide/libraries/uri.html

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

You can get:

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

Using:

$array = $this->uri->uri_to_assoc(3);

You can also find useful $this->uri->segment_array() .



来源:https://stackoverflow.com/questions/4245416/code-igniter-send-url-as-param

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!