How to get id from url in php cake

This is my action url from which I would like to get 16.

http://localhost/carsdirectory/Galleries/add/16 

Please help me.

+6
source share
2 answers
 $this->params['pass'] 

Returns an array (with a numerical index) of the URL parameters after the action.

 // URL: /posts/view/12/print/narrow Array ( [0] => 12 [1] => print [2] => narrow ) 

Another method: just pass the parameter to the function itself, as shown below:

 function add($id=null) { echo $id; } 

this will return your id

+9
source

Sorry I'm not familliar with phpcake, but you can use Regular Expression
See Attached Links
Php regex
CakePhp Custom Regular Expression Validation

-2
source

Source: https://habr.com/ru/post/910331/


All Articles