Subscribe To Our Newsletter

Sign Up Now To Get Free Coupon Codes, Event Coupon Codes Updates, Offers Updates. It's 100% Free!

We Hate Spam! Really, It's terrible and we never do it.

Switch Statement in PHP

php switch statement

Switch statement is conditional statement. It is used same as if else if statement. It is used to find the best condition. Its simple code is given bellow


 <?php  
                          $name="Feroz"; //Need to asign a value to variable  
                switch ($name) //need to add variable which needs to optimise for condition  
                               {  
                                    case "Sami":   
                                    echo "I am Sami";  
                                    break;  
                                    case "ullah":  
                                    echo "I am Samee Ullah";  
                                    break;  
                                    case "sheikh":  
                                    echo "I am Sheikh";  
                                    break;  
                                    case "Feroz":  
                                    echo "I am Samee Ullah Feroz";  
                                    break;  
                                    default:  
                                    echo "I m Samee Ullah Feroz cast sheikh";  
                               }  
                          ?>  

Updated 22 Oct, 2013:
Some times, we forget to add break after completion of any case. It can create bug in your output. Because in this situation, code will execute other cases and also will show their outputs.
Share this article :

Post a Comment

Give your reviews about this blog. Leave your comments. what do you think about this post?

Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe Samee Articles blog.

---------------------------------------
Thanks for visiting QWC.Me.
==========================================
For free guidelines contact me on SEO Expert | Samee Ullah Feroz is online there.
==========================================
Best Regards

 
Support : | Internet Marketing Specialist And Business Developer
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger