开发者

multiple vars via url question

I have a method

开发者_JAVA技巧
function checkin($var1){

$newVar1 = $var1;
....
...
}

I am calling it via Restful and I am passing it like this

$url = 'http://mydomain.com/controller/checkin/'.$var1;

Now i want to pass two variables but I am not sure how would it pick the second one I guess I can do this

$url = 'http://mydomain.com/controller/checkin/'.$var1.'/'.$var2;

not sure what would I do on receiving end to make sure it knows what var to use where. thanks


On the other end, you have to change your action method signature to

function checkin($var1, $var2){
    // (...)
}

Another option is using Cake's named parameters. That would require a change in both the url and the action:

URL

$url = 'http://mydomain.com/controller/checkin/var1:'.$var1.'/var2:'.$var2;

Action method

function checkin(){
    $var1 = $this->params['named']['var1'];
    $var2 = $this->params['named']['var2'];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜