Saturday, 16 September 2017

PHP Flow-Control Statements

In PHP, they are eight (8) flow-control statements. They are :-

  • If Loop
  • If...else Loop
  • If...elseif...else Loop
  • While Loop
  • Do...while Loop
  • Switch Statement
  • For Loop
  • Foreach Loop

Let me explain, each of them with a suitable examples.

Analyse the following screenshot:-

The code of the above page, is as follows:-


When we click on the "examples" of "If Loop", the output will be :-


The code of the above page, is as follows:-



When we click on the "examples" of "If..Else Loop", the output will be :-


The code of the above page, is as follows:-


When we click on the "examples" of "If..Elseif...Else Loop", the output will be :-

The code of the above page, is as follows:-


When we click on the "examples" of "While Loop", the output will be :-



The code of the above page, is as follows:-


When we click on the "examples" of "Do...While Loop", the output will be :-


The code of the above page, is as follows:-


When we click on the "examples" of "Switch" Statement, the output will be :-


The code of the above page, is as follows:-



When we click on the "examples" of "For Loop", the output will be :-

The code of the above page, is as follows:-


When we click on the "examples" of "Foreach Loop", the output will be :-

The code of the above page, is as follows:-





No comments:

Post a Comment