Friday, November 16, 2012

Branching at PHP

There are 4 branching at PHP, they are :

  1. if statement
  2. if...else statement
  3. if...elseif...else statement
  4. switch statement

1. If statement are a conditional statement which is use to execute a statement when condition of valuable is true. Below is basic script of if statements.

           if  (condition){
                statements
           }

example:

Click show to see and copy this code 


Let's see output above.



2. If...else statement are a conditional statement which is use to execute a statement when condition of valuable is true and another statement will execute if valuable is false. Below is basic script of If...else statement.

          if  (condition){
               statements
          }else {
               statements
          }

example:

Click show to see and copy this code 


Let's see output below.



3. If...elseif...else statement are a conditional statement which is use to select one of several condition and execute the selected statement of condition. Below is basic script of if...elseif...else statement.

          if  (condition){
               statements
          }elseif (condition){
               statements
          }else {
               statements
          }

example:

Click show to see and copy this code 


Let's see output below.



4. Switch statement are same with If...elseif...else statement, but switch statement only use to comparing single variables with some values is there. Below is basic script of switch statement.

          switch($n){
             case n_1:
                 statement 1;
             break;

             case n_2:
                 statement 2;
             break;

             default:
                 statement 3;
             break;
          }

example:

Click show to see and copy this code 


Let's see output below.



Thanks for visiting and reading my article. See you at next my posting...

Learn and learn again...

7 comments:

  1. Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article.
    Python Online certification training
    python Training institute in Chennai
    Python training institute in Bangalore

    ReplyDelete
  2. Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.
    AWS Training in pune
    AWS Online Training

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Concept involves in the contents are very beneficial, put the hands together for all your Effective works.To get More Beneficial Click on here...
    python training in chennai | python training in annanagar | python training in omr | python training in porur | python training in tambaram | python training in velachery

    ReplyDelete