2.7. Control Structures

PHP supports a variety of the most common control structures available in other programming languages. They can be basically divided into two groups: conditional control structures and loop control structures. The conditional control structures affect the flow of the program and execute or skip certain code according to certain criteria, whereas loop control structures execute certain code an arbitrary number of times according to specified criteria.

2.7.1. Conditional Control Structures

Conditional control structures are crucial in allowing your program to take different execution paths based on decisions it makes at runtime. PHP supports both the if and switch conditional control structures.

2.7.1.1. if Statements

Get PHP 5 Power Programming 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.