-2
在Controller中最好顯示消息的方式是?必須顯示計數文章。在控制器中顯示消息的最佳方式
$c = count($articles);
if($c == 0) {
return "On site are 0 articles";
} elseif ($c == 1){
return "On site is 1 article";
} else {
return "On site are" . $c . "articles";
}
或:
if($c == 1) {
$text1 = 'is';
$text2 = 'article'
} else {
$text1 = 'are';
$text2 = 'articles'
}
return "On site" . $text1 . $c . $text2;
也許其他的方式?
你有點忽視OP正在試圖*正確*複數詞「文章」。 – jprofitt