Chapter 3. CONTROL STATEMENTS

Topics in This Chapter

  • True and False

  • The if Statement

  • The ? Operator

  • The switch Statement

  • Loops

  • The while Statement

  • The break Statement

  • The do...while Statement

  • The for Statement

  • The foreach Statement

  • exit, die, and return

  • Evaluation of Boolean Expressions

Control statements allow you to execute blocks of code depending on conditions. They also allow you to repeat a block of code, which leads to simpler, more efficient scripts. This chapter will introduce you to the decision-making statements if and switch. You will also learn about loops using for and while.

Get Core PHP Programming: Using PHP to Build Dynamic Web Sites 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.