Wednesday, 26 February 2014

While Loops in php

This tutorial is of While Loops. In php,why we need loops during programming ? Here we may repeat certain amount of actions for a specified amount of times.

 Code for While Loop (Screenshot1):-

While Loops in php
Screenshot1

Output (Screenshot2) :-

while php
Screenshot2


In this example we have echoed out “Hello” by while loop.In this loop 1 evaluates true which echo out “Hello” but what if we want to echo out “Hello” 100 times! Let see example,how to echo out “Hello” for 10 times.

Code for While Loop (Screenshot3):-

Code for while loops in php
Code for while Loops Screenshot3

Output (Screenshot4):-

php while code
Screenshot4
In this example, we have starter counter which initialize/starts loop and condition counter which must be less than or equal to 10 that will be incremented again and again upto the limit of condition counter and thus echo out “Hello” 10 times.

Code for While loop (Screenshot5):-

While Loops
Screenshot5

Ouput (Screenshot6) :-

loops
Screenshot6
In this example condition will false and will not display “Hello” because condition counter is greater than 10.


No comments:

Post a Comment

Thanks For Comment Will get you Soon..

About Me

Welcome to Extra Tutorials! My name is Mohammed and I am the 22 year writer, website developer, and photographer behind the blog. Thanks for visiting! Tutorials Jackpot… In addition to Developer, I love to develop websites and I love to write. Starting a php Blog was inevitable for me. What began as a simple way to share all of my Tutorials with friends and family has developed into my Part time job.

Mohammed Padela

WHAT IS PHP PROGRAMMING

WHAT IS PHP PROGRAMMING
WHAT IS PHP PROGRAMMING

Follow Us

Popular Posts

Designed ByBlogger Templates