[ Team LiB ] Previous Section Next Section

Summary

In this hour, you learned about control structures and the ways in which they can help make your scripts flexible and dynamic. Most of these structures will reappear regularly throughout the rest of the book.

You learned how to define an if statement and how to provide for alternative actions with the else if and else clauses. You learned how to use the switch statement to change flow according to multiple equivalence tests on the result of an expression. You also learned about loops—in particular, the while and for statements—and learned how to use break and continue to prematurely end the execution of a loop or skip an iteration. You learned how to nest one loop within another and saw a typical use for this structure. Finally, you looked at a technique for using PHP start and end tags in conjunction with conditional code blocks.

You should now have enough information to write scripts of your own. Your scripts can now make decisions and perform repetitive tasks. In the next hour, we will examine a way of adding even more power to your applications. Functions will enable you to organize your code, preventing duplication and improving reusability.

    [ Team LiB ] Previous Section Next Section