O'Reilly logo

PHP, MySQL, & JavaScript All-in-One For Dummies by Richard Blum

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2

PHP Flow Control

IN THIS CHAPTER

check Adding conditional tests

check Looping through code

check Building functions

check Working with event-driven programming

In the preceding chapter, I cover the basics of creating and running PHP programs. I show you how to use variables to hold data, but you don’t really do much with them to test the data and perform operations. In this chapter, I walk through how to use the PHP conditional tests to control how your program behaves, as well as show how to loop through code to perform multiple iterations. In case you have code that you find yourself using frequently, I show how you can convert them into functions to share among your programs. Finally, I cover how to use PHP code in your event-driven web applications to add to your dynamic web applications.

Using Logic Control

Only having variables and echo statements in your PHP program would be pretty boring. You need to give your programs some intelligence so that they can make decisions based on what's happening in the application and display different sets of content based on those decisions.

Every programming ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required