有没有办法在不执行此冗余代码的情况下测试范围:
if ($int>$min && $int<$max)
Run Code Online (Sandbox Code Playgroud)
?
像一个功能:
function testRange($int,$min,$max){
return ($min<$int && $int<$max);
}
Run Code Online (Sandbox Code Playgroud)
用法:
if (testRange($int,$min,$max))
Run Code Online (Sandbox Code Playgroud)
?
PHP有这样的内置函数吗?或者其他任何方式吗?