While Loop


rkarim24

Say we have a website; and we will welcome to our new visitor by my name in 10 times. That is now we are going to write a program which will welcome him for ten times by this message”Welcome to Razaul Karim”. So we don’t need to echo this sentence for ten times bt this message. We just need a small program. that is:

<?php
$number=5;

while($number > 0):
echo “Welcome to Razaul Karim”.”<br/>”;
$number–;

endwhile;
?>

The result is:

Welcome to Razaul Karim
Welcome to Razaul Karim
Welcome to Razaul Karim
Welcome to Razaul Karim
Welcome to Razaul Karim

Structure:

First we set a value in a variable. Then while then include the condition in the parentheses. Then the message that will display if the condition fulfill. Then Decrementing Operator. At the end we finish the while loop by endwhile.

How it works:

The work of while loop is…

View original post 85 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s