Possible Duplicate:
What is “:” in PHP?
What does the :
mean in the following PHP code?
while (have_posts()) : the_post();
?>
Answer
It's called an Alternative Syntax For Control Structures. You should have an endwhile;
somewhere after that. Basically, it allows you to omit braces {}
from a while to make it look "prettier"...
As far as your edit, it's called the Ternary Operator (it's the third section). Basically it's an assignment shorthand.
$foo = $first ? $second : $third;
is the same as saying (Just shorter):
if ($first) {
$foo = $second;
} else {
$foo = $third;
}
No comments:
Post a Comment