$foo=false will never work as it is tha assign operator.
$foo == false is required
![]() | 章 16. 流程控制任何 PHP 脚本都是由一系列语句构成的。一条语句可以是一个赋值语句,一个函数调用,一个循环,甚至一个什么也不做的(空语句)条件语句。语句通常以分号结束。此外,还可以用花括号将一组语句封装成一个语句组。语句组本身可以当作是一行语句。本章讲述了各种语句类型。 ifif 结构是很多语言包括 PHP 在内最重要的特性之一,它允许按照条件执行代码片段。PHP 的 if 结构和 C 语言相似: 如同在表达式一章中定义的,expression 按照布尔求值。如果 expression 的值为 TRUE,PHP 将执行 statement,如果值为 FALSE - 将忽略 statement。有关哪些值被视为 FALSE 的更多信息参见转换为布尔值一节。 如果 $a 大于 $b,则以下例子将显示 a is bigger than b: 经常需要按照条件执行不止一条语句,当然并不需要给每条语句都加上一个 if 子句。可以将这些语句放入语句组中。例如,如果 $a 大于 $b,以下代码将显示 a is bigger than b 并且将 $a 的值赋给 $b: if 语句可以无限层地嵌套在其它 if 语句中,这给程序的不同部分的条件执行提供了充分的弹性。 ![]()
29-May-2006 04:07
$foo=false will never work as it is tha assign operator.
abu_hurayrah at hidayahonline dot org
25-May-2006 04:42
Regarding lamfeust's example:
dougnoel
06-May-2006 09:29
Further response to Niels:
roan dot kattouw at home dot nl
09-Dec-2005 08:49
In response to Niels: The ANSI C standard also dictates this laziness .
niels dot laukens at tijd dot com
26-Dec-2004 11:49
For the people that know C: php is lazy when evaluating expressions. That is, as soon as it knows the outcome, it'll stop processing. | ![]() |