I can't figure this out.
If I type:
function myfunction(){
......
if ...
return TRUE;
if ...
return FALSE;
}
为什么我不能像这样使用它:
$result = myfunction();
if ($result == TRUE)
...
if ($result == FALSE)
...
我需要使用什么:
或者我必须使用:
$result = myfunction();
if ($result == 1)
...
if ($result == 0)
...
或者这个:
$result = myfunction();
if ($result)
...
if (!$result)
...
if … return true; else return false;
应始终重写为return … === true;
或在类型安全的语言中,简单地重写为return …;
。 这里的if
没有意义,因为我们正在测试的条件已经对应于返回值。 - Konrad Rudolph