PHP for Keyword

❮ PHP Keywords

Example

Print even numbers less than 10:

<?php
for($i = 0; $i < 10; $i += 2) {
  echo "$i <br>";
}
?>
Try it Yourself »

Definition and Usage

The for keyword is used to create a for loop, which loops through a block of code a specified number of times.


Related Pages

Read more about for loops in our PHP for Loop Tutorial.


❮ PHP Keywords
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.