Sunday, September 16, 2012

PHP Switch Statement Tutorial with Practical Example

What is PHP Switch Statement?

According to The Switch Statement is similar to a series of IF statements on the same expression. In many occasions, you may want to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to. This is exactly what the switch statement is for.

PHP Switch  Statement Syntex

switch (n)
case label1:
  code to be executed if n=label1;
case label2:
  code to be executed if n=label2;
  code to be executed if n is different from both label1 and label2;

PHP Switch  Statement Practical Example

Objective : Creating a program to enter two number and select task from list then display the result.

case 'add':
case 'sub':
case 'mul':
case 'div':
<form action="" method="post">
Enter First Number<input type="text" name="t1"><br>
Enter Second Number<input type="text" name="t2"><br>
Result<input type="text" value="<?php echo $res;?>"><br>
Select Task:&nbsp;&nbsp;&nbsp;
<input type="radio" name="choice" value="add">ADD
<input type="radio" name="choice" value="sub">SUB
<input type="radio" name="choice" value="mul">MUL
<input type="radio" name="choice" value="div">DIV<br>
<input type="submit" name="done" value="DONE">

Delicious Save this on Delicious


  1. Ηi, i think that i saw уou viѕitеd my sіte thus i came
    to “гetuгn the favor”.I'm attempting to find things to improve my web site!I suppose its ok to use some of your ideas!!

    my blog post website advertising
    Also visit my web-site :: Submit your website

  2. Hello! What a amazingly looking personal site you run! Did you build your blog by yourself?

  3. NICE BLOG!!! Thanks for sharing useful information about FNT Softwre Solutions and being one of best Software Training institute in Bangalore we agree that this blog is very useful for the students are Searching for best software courses, I would really like to come back again right here for like wise good articles or blog posts. Thanks for sharing...PHP Training Bangalore .

  4. Nice blog...Very useful information is providing by ur is a way to find

    Php training institute in bangalore

  5. Hi, Its really very informative and useful blog..Thanks for sharing this useful information about PHP Course.

    PHP Training

  6. Thanks for updating new information about web designing. Practically, you have shared lot of details about website designing. Also share your new updated details about website creation. Thanks mate.
    Web Designing training in Chennai

  7. Tutorial about web creations. Practically, website designing, web development and Seo tutorial have discussed in this blog. Gradually, it is helpful when we are going to website creation.

  8. your blog is very helpful to students....Click here to SeePhp Training in bangalore

  9. Thanks for sharing these niche piece of coding to our knowledge. Here, I had a solution for my inconclusive problems & it’s really helps me a lot keep updates…
    Web design training in Chennai


  10. Thanks for sharing this valuable post to my knowledge great pleasure to be here sas training in Chennai has great scope in IT industry. It’s an application suite that can change, manage & retrieve data from the variety of origin & perform statistical analytic on it, if anyone looking for best sas training in Chennai get into FITA…
    sas course in Chennai | sas institutes in Chennai

  11. Thanks for splitting your comprehension with us. PHP- It’s an open source server-side scripting language particularly designed for web development but even it’s used as a universal programming language. Make our website as user friendly and responsive, it helps you to get more visibility &familiarity in online.
    PHP Training Chennai

  12. Aticle gives a great information about SEM.Now i ready to face any problems in SEM. Thanks for giving worthful information.
    css3 Training in chennai | css3 Training chennai | css3 course in chennai | css3 course chennai

  13. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing. html5 Training in chennai | html5 Training chennai | html5 course in chennai | html5 course chennai

  14. Your article is very useful for me. Thanks for sharing the wonderful information. PHP Training in chennai | PHP Training chennai | PHP course in chennai | PHP course chennai

  15. Your posts is really helpful for me.Thanks for your wonderful post. I am very happy to read your post. PHP Training in chennai | PHP Training chennai | PHP course in chennai | PHP course chennai

  16. This is extremely helpful info!! Very good work. Everything is very interesting to learn and easy to understood. Thank you for giving information. CSS3 Training in chennai | CSS3 Training chennai | CSS3 course in chennai | CSS3 course chennai

  17. This is extremely helpful info!! Very good work. Everything is very interesting to learn and easy to understood. Thank you for giving information. PHP Training in chennai | PHP Training chennai | PHP course in chennai | PHP course chennai

  18. Your blog is really awesome. Thank you for your sharing this informative blog. Recently I did HTML5 Training in Chennai at FITA academy, Its really useful for me. Suppose if anyone interested to learn real time PHP Training in Chennai reach FITA.

  19. I have read your blog, it was good to read & I am getting some useful info's through your blog keep sharing...
    PHP Course in Chennai

  20. Hi, Thanks for sharing this valuable blog.I was really impressed by reading this blog. I did HTML Training in Chennai at reputed HTML5 Training Institutes in Chennai. This is really useful for me to make a bright future in designing field.

  21. Your post about web design and development is really interesting. When comes to content management system, wordpress is widely used tool. It loaded with various stunning features that make website creation lot simpler. Wordpress Training in Chennai | Wordpress Course in Chennai | Wordpress Training Institutes in Chennai

  22. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    Oracle Training In Chennai

  23. Great post you could have completed the following. I'm truly happy to learn to read this kind of. This can be a very informative subject matter that you're picked. keep writing.Support Page

  24. Great tutorial, I like it. Thanks for sharing.

    php training in chennai

  25. It's a very useful post and your instruction is clear, Thanks for sharing this information.
    IT Job Training in Chennai


If you have any Question , Suggestion or idea then please comment regarding the post.