On Jan 19, 2008, at 831PM, Dave Smith wrote
Here's an example:
$condition = false;
$var = "bar";
// Here's the magic
$condition && $var = "foo";
echo $var;
If $condition is true, this will output "foo", otherwise, it'll
output "false".
This is called short-circuited because the interpreter is smart
enough to not evaluate the second half of an && if the first half is
false.
Be sure to use parentheses when your condition has multiple
conditions, like this:
($condition && $other_condition) && $var = "foo";
Keep in mind that this is a bit more difficult read than the standard:
if($condition == false && $var == "foo")
{
echo false
}
else
{
echo "foo";
}
especially if you've got multiple people working on the same code.
Brady
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net