Contents
hide
For Loop in PHP
| Code | Comment |
|---|---|
| <?php | //PHP opening tag |
| for( $i=0; $i <= 20; $i++){ | //First $i=0 is initialization $i <= 20 is condition check and $i++ is increment |
| if($i%2==0){ | //Check whether i is divisible by 2 if yes it is an even number |
| echo ” This is an even number $i”; } } | // Prints even numbers |
| ?> | PHP Closing tag |
________________________________________
The output you can see in video