Chapter 6. Flow Control Functions in PHP

The scripts created in the previous chapter flow only in a single directionforward. That is, the same statements are executed in the same order every time a script is run. This does not allow for much flexibility, as any sort of dynamic programming will at the very least need to have a loop or two, not to mention the ability to check for the validity of certain conditions before proceeding onward.

You will now learn about the programming structures that enable your scripts to adapt to circumstances. In this chapter, you will learn

  • How to use the if statement to execute code if a test expression evaluates to true

  • How to execute alternative blocks of code when the test expression of an if statement evaluates to false

  • How to use the switch statement to execute code based on the value returned by a test expression

  • How to repeat execution of code using a while statement

  • How to use for statements to make neater loops

  • How to break out of loops

  • How to nest one loop within another

  • How to use PHP start and end tags within control structures

Sams Teach Yourself PHP, MySQL And Apache All in One
Sams Teach Yourself PHP, MySQL and Apache All in One (3rd Edition)
ISBN: 0672328739
EAN: 2147483647
Year: 2004
Pages: 327 © 2008-2017.
If you may any questions please contact us: