Search code examples
phpcakephpcakephp-2.0urlvariables

CakePhp2 : How to get variables in an url like foo:bar/foo2:bar2/...?


I'm using CakePhp2 and trying to get values of variables from a url.

My url looks like controller/action/foo:bar/foo2:bar2/foo3:bar3 ?

When I use $this->request['foo'] CakePhp says "Undefined index".

Any idea to find values of foo, foo2 and foo3?


Solution

  • check the documentation on named params. it will most likely be in

    $this->request->params['named']
    

    or even easier/cleaner for 2.x:

    $this->request->named
    

    so debug($this->request->named) for details.