Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. Php Control flow | Php tutorials Bestitworriors
Php Control flow
Php Control flow | Php tutorials Bestitworriors - if-else statements,Switch Statements,Else if Statement,Iterative or looping Structure,While Loop,Do-while loop,For loop,Nested loop,Sequential Control Flow Structure,jump statements,Break statement,Continue statement .These ara all control flow in php code.
Some Key Points of Controls Flow
- if
- if-else statements
- Switch Statements
- Else if Statement
- Iterative or looping Structure
- While Loop
- Do-while loop
- For loop
- Nested loop
- Sequential Control Flow Structure
- jump statements
- Break statement
- Continue statement
Code
< ?php
echo
"While Loop<br>";
$condation = 1;
while ($condation <= 5) {
echo "The Condation is: $condation <br>";
$condation++;
}
echo
"<br>";
echo
"Do While Loop <br>";
$condation1 = 1;
do
{
echo
"The Condation is: $condation1 <br>";
$condation1 + +;
} while ($condation1 <= 5);
echo
"<br>";
echo
"For Loop<br>";
for ($cond = 0; $cond <= 5; $cond++) {
echo "The Condation is: $cond <br>";
}
echo
"<br>";
echo
"For each Loop<br>";
$months = array("january", "feburary", "march", "april");
foreach($months as $value) {
echo
"$value <br>";
}
echo
"<br>";
// Nester
For
Loop
echo
"<br>";
echo
"Nested For Loop";
for ($j=1;$j < 5;$j++)
{
for ($i = 0; $i < 5; $i++) {
echo "The number is: $i - $j <br>";
}
}
? >
OutPut
While Loop
The Condation is: 1
The Condation is: 2
The Condation is: 3
The Condation is: 4
The Condation is: 5
Do While Loop
The Condation is: 1
The Condation is: 2
The Condation is: 3
The Condation is: 4
The Condation is: 5
For Loop
The Condation is: 0
The Condation is: 1
The Condation is: 2
The Condation is: 3
The Condation is: 4
The Condation is: 5
For each Loop
january
feburary
march
april
Nested For Loop
The number is: 0 - 1
The number is: 1 - 1
The number is: 2 - 1
The number is: 3 - 1
The number is: 4 - 1
The number is: 0 - 2
The number is: 1 - 2
The number is: 2 - 2
The number is: 3 - 2
The number is: 4 - 2
The number is: 0 - 3
The number is: 1 - 3
The number is: 2 - 3
The number is: 3 - 3
The number is: 4 - 3
The number is: 0 - 4
The number is: 1 - 4
The number is: 2 - 4
The number is: 3 - 4
The number is: 4 - 4
The Condation is: 1
The Condation is: 2
The Condation is: 3
The Condation is: 4
The Condation is: 5
Do While Loop
The Condation is: 1
The Condation is: 2
The Condation is: 3
The Condation is: 4
The Condation is: 5
For Loop
The Condation is: 0
The Condation is: 1
The Condation is: 2
The Condation is: 3
The Condation is: 4
The Condation is: 5
For each Loop
january
feburary
march
april
Nested For Loop
The number is: 0 - 1
The number is: 1 - 1
The number is: 2 - 1
The number is: 3 - 1
The number is: 4 - 1
The number is: 0 - 2
The number is: 1 - 2
The number is: 2 - 2
The number is: 3 - 2
The number is: 4 - 2
The number is: 0 - 3
The number is: 1 - 3
The number is: 2 - 3
The number is: 3 - 3
The number is: 4 - 3
The number is: 0 - 4
The number is: 1 - 4
The number is: 2 - 4
The number is: 3 - 4
The number is: 4 - 4
0 Comments