Chapter 17 The Dual-Alternative Decision Structure

17.1 The Dual-Alternative Decision Structure

In contrast to the single-alternative decision structure, this type of decision control structure includes a statement or block of statements on both paths, as presented in the following flowchart fragment, given in general form.

Image

If Boolean_Expression evaluates to true, the statement or block of statements 1 is executed; otherwise, the statement or block of statements 2 is executed.

The general form of the PHP statement is

if (Boolean_Expression) {
A statement or block of statements 1
}
else {
A statement or block of statements 2
}

In the next example, ...

Get PHP and Algorithmic Thinking for the Complete Beginner now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.