bool和 == 运算的问题
在php官方的手册当中提供了这样一个例子:
<br /> Beware of certain control behavior with boolean and non boolean values :<br /> <br /> <?php<br /> // Consider that the 0 could by any parameters including itself<br /> var_dump(0 == 1); // false<br /> var_dump(0 == (bool)'all'); // false<br /> var_dump(0 == 'all'); // TRUE, take care<br /> var_dump(0 === 'all'); // false<br /> <br /> // To avoid this behavior, you need to cast your parameter as string like that :<br /> var_dump((string)0 == 'all'); // false<br /> ?> <br />