Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get id from url in cake php [closed]

This is my action URL of which I'd like to get the 16.

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

Please help me.

like image 260
thecodedeveloper.com Avatar asked Mar 09 '12 09:03

thecodedeveloper.com


1 Answers

$this->params['pass']

Returns an array (numerically indexed) of URL parameters after the Action.

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

Another Method is - Just pass the parameter to the function itself like as follows:

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

this will return your id

like image 160
Ben Avatar answered Sep 27 '22 20:09

Ben