哪种方式最好在 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;
也许其他方式?