Use loop control of the flow of php

 

Use the loop

Wang students need to repeatedly back and forth to Beijing and Dalian, it is a typical cycle structure. Wong Sze assume a total investment of this project need to travel Dalian 100 times per round are the king of the students will be counted once. Do we write the same code a hundred times? Clearly it can not deal with such a high IQ for programmers.

We abstract the human kind of thinking. We define a loop structure Wuxi marble measurement platform

? <PHP 

// define the required number of round-trip, foreigners prefer to start counting from zero, we have to start from zero count 
$ count = 0; 

behind // while connected to a Boolean value judgment, execution is true, false stop 
// $ count less than 100 when executed, i.e. $ count is 0-99 when executed 
// if $ count is not less than 100, the circulation is stopped to perform subsequent code 

// at the beginning of the cycle 
the while ($ count <100) { 

   echo 'I am a king always thinking, my first business trip /> <br '' $ count.. '; 
   // for each execution make $ count + 1, this is the case, it will not always generate $ count is less than 100, the 
   $ count ++; 

/ / cycle ends 
} 

echo 'of the succeeding code'; 
?>

We can make up for some specialized code loop logic diagram for the while:

2.png

Guess you like

Origin www.cnblogs.com/furuihua/p/12066444.html