O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.1. The if Statement

Figure 3.1 lays out the form of an if statement.

Figure 3.1. The form of an if statement.
						if(expression1)
{
    This block gets executed if expression1 is true.
}
elseif(expression2)
{
    This block gets executed if expression1
    is false and expression 2 is true.
}
else
{
    This block gets executed if both expression1
    and expression2 are false.
}

The if statement executes a statement if the expression inside the parentheses evaluates to true; otherwise, the code is skipped. It may be a single statement followed by a semicolon. Usually it's a compound statement surrounded by curly braces. An else statement may appear immediately after the statement and have a statement of its own. It too may be either single or compound. It is executed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required