Home >Backend Development >PHP Problem >What does for mean in php
For in php refers to the PHP for loop statement, which can loop and execute the code block a specified number of times. Its usage syntax is such as "for (init counter; test counter; increment counter) {...}" .
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What does for mean in php?
PHP for loop executes the code block a specified number of times.
If you have determined in advance the number of times the script will run, you can use a for loop.
Syntax
for (init counter; test counter; increment counter) { code to be executed; }
Parameters:
init counter: Initializes the value of the loop counter
test counter:: Evaluates each loop iteration. If the value is TRUE, continue looping. If its value is FALSE, the loop ends.
increment counter: increase the value of the loop counter
The following example shows the numbers from 0 to 10:
Example
<?php for ($x=0; $x<=10; $x++) { echo "数字是:$x <br>"; } ?>
Recommended learning:《 PHP video tutorial》
The above is the detailed content of What does for mean in php. For more information, please follow other related articles on the PHP Chinese website!