开发者

code igniter :: send url as param?

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 setti开发者_运维百科ngs is a url.

How could I pass this in this way?


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


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() .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜