Home  >  Article  >  Backend Development  >  What does for mean in php

What does for mean in php

藏色散人
藏色散人Original
2021-11-09 11:13:582516browse

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) {...}" .

What does for mean in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn