Sequence and control structure There was a great God who said that the program can be as long as three kinds of structure. In fact, the computer developed for so many years, the three major structures used today. They are: Order control loop. sequential structure: In simple words, a line of code is from top to bottom, one line at a line. control structure: In layman's terms, the sequential structure adds a branch to control the direction of the code. For example: if else if the condition goes, this line is reversed, then go else this one. In the previous code, such a judgment statement occurred multiple times. cycle structure: The loop structure can be seen as a combination of a conditional judgment statement and a return-to-turn statement. In addition, there are three elements of the cyclic structure: The loop variable, the loop body, and the loop termination condition. 1 We look at the control structure first, the code is as follows: <? Php$today=3; if ($today ==1) { echo ' 1th '; } else if ($today ==2) { echo ' second '; } else if ($today ==3) { echo ' third '; ///print this line. } else if ($today ==4) { echo ' IV '; } else{ echo ' V '; }?> & nbsp This is a standard control structure, I use the popular words again. The variable $today value is 3 o'clock, go down, if (if) $today equals 1, then print (echo) ' first '. else (otherwise), if (if) then judge, or go else again if (today==3) This is true and the direct echo ' third '. Here is a joke, that is, in fact the furthest distance in the world is not life and death, but you in if, and I in else. Because, they can never print out when. 2. switch case <? Php$today=4; switch ($today) { case 1; echo ' first '; break; Case 2: echo ' second '; break; case 3: echo ' third '; &N Bsp break; case 4: echo ' IV '; Print fourth. break; default: echo ' last '; }?> this is shorthand for the previous program, save the code. Break damage When the program echo output, encounter it directly destroyed, do not go behind the program. End directly. When the case is not satisfied, the program executes the default that is echo ' last ' sentence. The seitch case is used to verify the use of multiple possible values. is not suitable for judging range such as: 0-59 failed, 60-100 for passing, it is the control structure, is not a shorthand way.
Five. PHP language Structure (1) Order and control structure