PHP

For loop: (PHP Tutorials: part-7)

Written by Saiful Islam

Usage of for loop?

For loop is used for executing a command rapidatly till the condition is true. To run a particular program on server rapidatatly without coding again and again we need to use the for loop.

Basic structure:

 

Example:1

Input

Output

   

 

Description:

  1. The value of x is 1.
  2. The limit of the value of x can be between 1 to 5.
  3. Because of using x++ the value of x will increase one by one.

Example:2

Input

Output

   

 

Description:

1.  The value of x has been shown through the echo statement which is commanded to decrease one by one.

  1. The “<br>” has been used as a HTML tag and it is used for creating a break after presenting each number(5, 4, 3, 2, 1).

  2. The dot (.) sign between $x and “<br>” has separated the value of x and the “<br>”

About the author

Saiful Islam

Leave a Comment