downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
Last updated: Mon, 16 Jul 2012


经常需要在满足某个条件时执行一条语句,而在不满足该条件时执行其它语句,这正是 else 的功能。else 延伸了 if 语句,可以在 if 语句中的表达式的值为 FALSE 时执行语句。例如以下代码在 $a 大于 $b 时显示 a is bigger than b,反之则显示 a is NOT bigger than b

if ($a > $b) {
"a is bigger than b";
} else {
"a is NOT bigger than b";

else 语句仅在 if 以及 elseif(如果有的话)语句中的表达式的值为 FALSE 时执行(参见 elseif)。

 Last updated: Mon, 16 Jul 2012
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at:
Last updated: Thu Jul 7 19:13:47 2005 CST