Himanshu Upadhyay
Himanshu Upadhyay

Reputation: 743

Get url parameter in cakephp 1.2.4.8284

I am using cake php version 1.2.4.8284

I have url like below

http://www.example.com/users/index/filter:/site:917+919/

But when i print this url in users controller with 'print_r($this->params);'

I get result like below.

Array
(
    [pass] => Array
        (
        )

    [named] => Array
        (
            [filter] => 
            [site] => 917 919
        )

    [controller] => users
    [action] => index
    [plugin] => 
    [url] => Array
        (
            [ext] => html
            [url] => users/index/filter:/site:917 919/
        )

    [form] => Array
        (
        )

    [isAjax] => 
)

Here you can see + is missing from 'site' and 'url'.

But I want exact url and site value. Please Help.

Upvotes: 1

Views: 71

Answers (2)

drmonkeyninja
drmonkeyninja

Reputation: 8540

The + character represents a space in a URL so print_r($this->params) is returning the correct value. If you want your url to include an actual + character you need to URL encode it as %2B; so your URL would be:-

http:www.example.com/users/index/filter:/site:917%2B919/

You might want to take a look at the PHP docs about urlencode.

Upvotes: 1

Shaharia Azam
Shaharia Azam

Reputation: 1978

Your URL must be encoded to get the actual symbol.

http:www.example.com/users/index/filter:/site:917%2B919/

Upvotes: 1

Related Questions