Regarding if statements in PHP
I've seen some PHP statements that go something like
if($variable) {} or
if(function()) {} (if statements that don't compare two variables)
and I know they roughly mean if a function executes or if this variable exists but I can't seem to find any information on how they work specifically. Can anybody shed some light on this?
if(function()) {}
表示函数函数的返回值是真还是假,则块将执行。
From the PHP manual:
if (expr) statement
As described in the section about expressions, expression is evaluated to its Boolean value. If expression evaluates to TRUE, PHP will execute statement, and if it evaluates to FALSE - it'll ignore it.
So, if a function successfully runs (true) or a variable exists (true) the if statement will continue. Otherwise it will be ignored.
The if statements determine whether the given variable is true or a given function returns true. A variable is considered "true" if it isn't null, false, 0, or (perhaps) an empty string.
链接地址: http://www.djcxy.com/p/58862.html上一篇: 如何区分命令
下一篇: 关于PHP中的if语句