如何从蛋糕php中的URL获取id [关闭]
问题描述:
This is my action URL of which I'd like to get the 16.
http://localhost/carsdirectory/Galleries/add/16
Please help me.
这是我想要获取 16 em>的行动网址。
请帮助我。 p >
div>
http:// localhost / carsdirectory / Galleries / add / 16
code> pre>
答
$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
答
Sorry i'm not familliar with phpcake but you Can use Regular Expression
See Attached Links
Php Perform Regular Expression
CakePhp Custom Regular Expression Validation