RSS

Control structure

Sat, Jul 19, 2008

PHP

There are 6 kinds of control structure in PHP:

  • If
    • If (condition){Statements}
  • Ternary operator
    • (condition)?(Statement1):(Statement2)
  • Switch
    • switch(expression){

case value-1:

statements;

break;

case value-2:

statements;

break;

case value-n:

statements;

break;

case default:

statements;

break;

}

  • While(or Do while)
    • While(condition){statements;}
    • Do{statements}While(condition);
  • For
    • For(initial-value;termination-check;loop-end-expression){statements;}
  • Exit(or die)
    • exit(”strings or number”);
    • die(”strings or number”);
    • Just terminate the script immediately after the exit(or die) function;

Related Posts

Tags: , , , , , , , , ,
Trackback URL:

This post was written by:

cXY - who has written 23 posts on cXY Lab.


Contact the author

Leave a Reply