Test Forbrukslån | Hiiri | Kredittkort Test | Billig Strømleverandør | Sammenlign Innbruddsalarm | Helseforsikring | Mobilselskaper i Norge | Verditakst
Php

PHP Looping statement tutorial

The Sims Mobile

Statement looping a very important role in programming. Some of the statements looping statements are used for carrying out a parturition. On the basis of certain conditions, looping the loop begins and continues until the condition until it ceases to exist. A skilled programmer to the idea of looping and a detailed knowledge of the application is very important.

Construction of looping statement

  • while statement – on the basis of a looping condition continues. When the condition is false, the looping looping off. Syntax while (expression) {statements}.
  • do-while statement – while statement is similar to the conditions on the basis of a looping continues. When the condition is false, the looping looping off while Pak difference in the statements, and do-while statement to check the conditions before the conditions are tested. Syntax do {statements} while (expression);
  • Statement for – for three expressions commonly used statement. The first expression of a particular variable starts by taking an initial value, the second run lupati expression can be variable, indicating that the maximum or minimum. How to change the expression and the third lupati parturition indicating whether each of the
  • variable quality. Syntax for (expression; expression; expression 3) {statements}
  • for each statement – foreach statement is used for Array. Syntax for each (array_expr as $ value) {statement} The first was an Array. The number of loops depends on the number of array elements. (Array_expr as $ value) of each array element is adopted as the value of the variable $ value.

Practice Project

<html>
<head>
<title> www.trickbd.com.bd</title>
<style>
body{background: #00cc99 ; color: #000000;}
</style>

</head>
<body>
<?php
echo “<h2>Example of while loop</h2>”;
$a = 1;
while ($a < 6) {
echo “A = “.$a.”<br />”;
$a++;
}
?>
<?php
echo “<h2>Example of do-while loop</h2>”;
$b = 1;
do{
echo “B = “.$b.”<br />”;
$b++;
}while ($b < 6)
?>
<?php
echo “<h2>Example of for loop</h2>”;
$i = 1;
for($i;$i<6;$i++)
{
echo “I = “.$i.”<br />”;
}
?>
<?php
echo “<h2>Example of foreach loop</h2>”;
$test = array(1,2,3,4,5);
foreach($test as $list)
{
echo “List = “.$list.”<br />”;
}
?>

</body>

</html>

After writing the above Kodak a notepad click the File menu, click Save as index.php in the File name in the Save as type, select All files by clicking on the Save to Save. index.php file C: \ xampp \ htdocs should be in the htdocs folder. Htdocs folder to the Desktop Shortcut to the action easily could be put in. If XAMPP Running index.php file in the browser address bar to show the will to write http: //localhost/index.php. And if a new folder in the htdocs folder create a folder named as the site of the index.php file is to write to the browser’s address bar http://localhost/site/index.php. If the browser look like the image below.

Use of the program is shown at the top of looping statement.

Comments

comments

About the author

Toriqul Islam Tusher

বলার মত কিছু নাই!

Leave a Comment