Wednesday, October 3, 2012
PHP Control Structures
PHP control structures owned similar to other programming languages.
There are 2 types of control structures, namely:
1. branching structure
2. Structural repetition
A. Branching structure
Is a command that allows the selection of the command to be executed in accordance with certain conditions.
3 orders of branching in PHP:
a. IF
Used to run one or more commands before checking with many given conditions, if the condition is true then a series of statements will be made, if the condition is false then the statement will be executed for the wrong condition.
b. IF ... ELSE
A command similar to the previous command, but the command block is used to many different conditions
c. SWITCH
Alternative command structure for a replacement IF .. ELSE with else rather than one that makes the program easier to understand.
B. Repetition structure
Used to repeat a command. There are 3 kinds of loop in PHP, namely:
a. FOR, used to repeat the order with a known number of repetitions.
b. While, used to repeat a command to a certain amount. Having a final value true or false and the loop will continue as long as the condition is true.
c. Do ... While, almost as denagn while but looping commands will be done first and will stop when it stops search certain conditions.
Labels:
PHP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment