I am using cakephp v1.26.
I got a function in a controller like this:
class testingsController extends AppController{
function testing($id=null){
$recieved = $id;}
}
I am not sure if there are any better ways to pass a parameter to the Action testing.
But I have come across some web sites and got these two methods.
Is there any difference in the following parameter passing methods?
1. url/testings/testing/1
2. url/testings/testing:1
With standard routes, this will call
TestingsController::testing(1).This is standard parameter passing, any parameters beyond
/:controller/:action/are passed “as-is” to the called action./controllers/action/param1/param2corresponds toControllersController::action($param1, $param2)With standard routes, this will call
TestingsController::index()andset
$this->params['named']['testing']to1. This is known as a named parameter.Named parameters can be passed in any order. These two URLs are equivalent:
url/testings/testing:1/foo:2url/testings/foo:2/testing:1They will not be passed to the function, as in
function testing($id = null).$idwill benull. They’re only available in the$this->params['named']array.