有沒有一種方法可以根據()內傳遞的內容返回部分函數?舉個例子:PHP根據參數返回函數的不同部分
function test($wo) {
if function contains $wo and "date" {
//pass $wo through sql query to pull date
return $date
}
if function contains $wo and "otherDate" {
//pass $wo through another sql query to pull another date
return $otherDate
}
if function only contains $wo {
//pass these dates through different methods to get a final output
return $finaldate
}
}
日期:
test($wo, date);
返回:
1/1/2015
otherDate:
test($wo, otherDate);
返回:
10/01/2015
正常輸出:
test($wo);
返回:
12/01/2015
你將不得不放棄一個更好的例子有預期的輸入/輸出等... – AbraCadaver
希望現在更清楚 –