PHP Loops
Posté 2024-05-17 07:48:35
0
2KB
In the following chapters you will learn how to repeat code by using loops in PHP.
PHP Loops
Often when you write code, you want the same block of code to run over and over again a certain number of times. So, instead of adding several almost equal code-lines in a script, we can use loops.
Loops are used to execute the same block of code again and again, as long as a certain condition is true.
In PHP, we have the following loop types:
while
- loops through a block of code as long as the specified condition is truedo...while
- loops through a block of code once, and then repeats the loop as long as the specified condition is truefor
- loops through a block of code a specified number of timesforeach
- loops through a block of code for each element in an array
The following chapters will explain and give examples of each loop type.
Rechercher
Catégories
- Art
- Causes
- Crafts
- Dance
- Drinks
- Film
- Fitness
- Food
- Jeux
- Gardening
- Health
- Domicile
- Literature
- Music
- Networking
- Autre
- Party
- Religion
- Shopping
- Sports
- Theater
- Wellness
Lire la suite
PHP Numbers
In this chapter we will look in depth into Integers, Floats, and Number Strings.
PHP Numbers...
PHP foreach Loop
The foreach loop - Loops through a block of code for each element in an array or each...
PHP Magic Constants
PHP Predefined Constants
PHP has nine predefined constants that change value depending on where...
PHP - $_SERVER
$_SERVER
$_SERVER is a PHP super global variable which holds information about headers,...
PHP Global Variables - Superglobals
Superglobals were introduced in PHP 4.1.0, and are built-in variables that are always available...