Online
 
Friday, 09 January 2009
 
 
More article:
Related Content:

PHP Control Structures
 
Article Index
PHP Control Structures
Page 2
Page 3

Although all the variable manipulations that have been covered thus far are wonderful, they leave much to be desired in terms of a real programming language. For that, you need control structures. Control structures are a facility that allows you to control the behavior of your programs. Control structures enable you to specify the circumstances under which code will be executed, generally based on the current state of the script. Often, they can even be (roughly at least) translated from plain English. To illustrate this, consider what is called a conditional statement in programming:

"If John finishes 15 pages of his book, then he can sleep."

How can this logic be transformed into a computer program that can tell me when it's all right for me to go to sleep? To compare how many pages I've written to how many I need to complete, I'll need to use the if statement. The if statement is unlike anything covered thus far and takes the following general form:

if(conditions) {

/* Code to execute if condition is true */

} [ else {

/* Code to execute if condition is false */

} ]



Tags: Add more tags...,
This entry was posted on . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a comment. Tags: Simple PHP, Pear, Easy PHP, PHP Tutorial, PHP MySQL, XSLT, Sap Tutorial, CSS Tutorial, XSL FO Java, SQL Tutorial.
Users' Comments (0)

Comment an article
  Name
  E-mail
   Title
Available characters: 4000
 Notify me of follow-up comments
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage
Enter what you see:

No comment posted

Mobile Wallpaper 206
Statistic


Last Post

 
Top! Top!