Process control - an alternative syntax

Process control: code execution direction

classification:

  Sequence Structure: down from the first performance     

  Branch structure: given a condition, various colleagues executable code (block), and then a piece of code will be executed according to the conditions

  Loop structure: within a range of conditions, a given block may be repeatedly performed

 

  if()else

  if()

  if () else if () else with the same cc #

 

  switch branch

  There exists a set of circumstances, the same condition, there are usually a plurality of values, but each corresponding to a different value are to be executed

  switch (conditional expression) {

    case values:

      To code execution;

      break;

      .......................

      default:

            break;

  }

Loop structure

  for:

  while:

  do-while:

  foreach: specifically for array

 

Loop control:

  continue: continue can be followed 12. 1 2 the current control of the present cycle within their structure no longer performs loop back, while the external loop circulation is not performed if there is.

  break: the back control may break out of this loop configuration with a current loop 2.1. 2 The current cycle ends themselves, but also the external end (if there is external unaffected)

 

 

Process Control Alternative syntax:

  PHP scripting language embedded in HTML itself, you need to write something about judgment or cyclic structure grammar, must comply with the PHP label specifications need to mix and match HTML and PHP, if you use the original PHP code that will be very pretty in html.

Use Form 99 multiplication table to print:

  

<body>
<table border=1>
    <?php for($i=1;$i<10;$i++){?>
        <tr>
            <?php for($j=1;$j<=$i;$j++){?>
                <td>
                    <?PHP
                        echo $i.'*'.$j.'='.$i*$j;
                    ?> 
                </td>
            <?PHP }?>
        </tr>
    <?php }?>
</table>
</body>

  Using the above writing to the html code php of these very unsightly braces {}, the PHP provided an alternative mechanism for additional braces can not write;

  <?php for($i=1;$i<10;$i++):?>

  <?php endfor;?>

  Braces began to express a colon: End with endfor (if it is for) is if endif

 

  PHP syntax in which specific alternatives it?

     PHP should only in HTML output, the output condition determination and usually accompanied by cyclic operation, thus providing an alternative PHP syntax corresponding to a branch structure and a cyclic structure: are all a pattern corresponding to:

    Use braces {left colon alternative:

    Zip braces} using the time stamp which corresponds to end + alternatively

      if,switch,for ,while foreach,等

 

Guess you like

Origin www.cnblogs.com/xiaowie/p/10966446.html