本文介绍了变量的单数或复数设置.PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多问题解释了如何回显单数或复数变量,但没有人回答我的问题,即如何设置变量以包含所述单数或复数值.

There are a lot of questions explaining how to echo a singular or plural variable, but none answer my question as to how one sets a variable to contain said singular or plural value.

我原以为它会按以下方式工作:

I would have thought it would work as follows:

$bottom="You have favourited <strong>$count</strong> " . $count == 1 ? 'user':'users';

然而这不起作用.

有人可以建议我如何实现上述目标吗?

Can someone advise how I achieve the above?

推荐答案

这将解决您的问题,感谢 mario 和 三元运算符和字符串连接的怪癖?

This will solve your issue, thanks to mario and Ternary operator and string concatenation quirk?

$bottom = "You have favourited <strong>$count</strong> " . ($count == 1 ? 'user':'users');

这篇关于变量的单数或复数设置.PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 02:08