CakePhp2 : How to get variables in an url like foo:bar/foo2:bar2/…?
-
01-07-2021 - |
Pregunta
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?
Solución
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.
Otros consejos
Try
$this->passedArgs
OR
$this->request->params['pass']
You want to access the passed arguments.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow