有这样的事情吗?
例如
$var = -5;
echo thefunction($var); // should be 0
$var = 5;
echo thefunction($var); // should be 5
最佳答案
试试max($var,0)
,会有想要的效果。见 manual page了解更多信息。
关于php - 将负数变为 0 的默认 php 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6566187/