Default php function that turns negative numbers in 0

前端 未结 5 718
谎友^
谎友^ 2020-12-29 01:01

Is there such a thing?

for eg

$var = -5;
echo thefunction($var); // should be 0


$var = 5;
echo thefunction($var); // should be 5
5条回答
  •  灰色年华
    2020-12-29 01:27

    Try max($var,0), which will have the desired effect. See the manual page for more information.

提交回复
热议问题