我有一個非常簡單的類,它派生自Restler網站上給出的示例「Say」類。這是因爲如下:Restler 3 - 參數的默認值阻止了參數傳遞的能力
<?php
class Say {
function hello($to='world') {
return "Hello $to!";
}
function hi($to) {
return "Hi $to!";
}
function nothing($to='the ground') {
return "Looks at {$to} quietly but without saying a word.";
}
}
因爲「喜」功能沒有爲$變量的默認值它在很大程度上做了它應該:
http://localhost/api/say/hi/Jack
回報
嗨,傑克!
大。問題是,當你有像「你好」或「無」功能的默認值的話,好像你不能在參數傳遞了:
http://localhost/api/say/hello -- WORKS, returns "Hello world!"
http://localhost/api/say/hello/Jack -- FAILS, returns a JSON error of 404
任何幫助將不勝感激。
在一個側面說明,我也注意到,如果你不使用帶有「喜」的參數(這需要$設置爲東西),它會返回404錯誤也是如此。我不確定這是否是預期的行爲,但它似乎是這種錯誤的錯誤信息。