Contents

PHP tutorials

Introduction

Syntax

Variables

Data Types

Operators

echo

If/Else

Loops

chmod()

mail()

date()

phpinfo()

 

 

while Loops

The simplest kind of loop in PHP is the while loop. Like an if statement, it relies on a condition. The difference between a while loop and an if statement is that an if statement executes the following block of code once if the condition is true. A while loop executes the block repeatedly for as long as the condition is true.

<?php

$number = 1;
while($number < 10)
  {
  echo "Now the number is " . $number . "<br />";
  $number++;
  }

?>

 

 

for Loops

Using a for loop this source code will seems differently and more compact.

<?php

for( $number = 1; $number < 10; $number++ )
  {
  echo "Now the number is " . $number . "<br />";
  }

?>