Control structures give you the ability to do more sophisticated tasks with your scripts. Say for example you have an Excel spreadsheet with a list of addresses in CSV format, and you wanted to enter the information into a database. You could do it manually (quite a laborious, inefficient, and expensive task), or you could have PHP do it for you. How can you get PHP to loop through all the information? You can use one of the following control structures:
Say you wanted to skip addresses that aren't located in the United States. How can you get PHP to differentiate between the data? Using conditionals of course! The following terms represent some conditional statements in PHP:
With conditionals, you need to use operators to test your conditions. Here are some examples:
As well as:
A conditional mostly tests for truth. For example, the following code is asking whether what is between the parentheses is true:
<?phpif(5==2) { // then...}?>
In this case the condition is not true, so PHP will not execute what is between the curly brackets. Along these lines, you can use functions that return a boolean value of true of false. For example, the function:
<?phpisset()?>
returns a true/false value depending on whether a variable is set.
PHP Tasks:
PHP Resources:
http://www.quepublishing.com/articles/article.asp?p=381922&rl=1