The function switch() in PHP is used to execute different codes based on a variable’s value. This is used in place of the IF/ELSE IF statements. A default value is optional and, if specified, is used when no other option is matched. You must include a break; after each case or the following cases will all return true.
[code lang=”php”]
[/code]
You can use this with forms and such to determine an action based on a submitted value as well! Here is an example using the switch() function in a form:
[code lang=”html”]
[/code]
Now on our PHP side of the script (submit.php) we will use the switch() function to evaluate the value.
[code lang=”php”]
[/code]
Nice article.
very good blog!.. awesome templates as well ! 🙂
Great text and nice blog.
I was just having a conversation over this I am glad I came across this it cleared some of the questions I had.
I stumbled across your blog and think it’s fantastic, keep us posting
I was bored until i’ve found your blog, interesting posts
I’ve just started off a blog, the knowledge you give on this site has aided me extremely. Thank you for all your time & work.
Thanks for this great blog.
Thanks for this article, it was great to read.
Very good article. Coherent and informative just like a good article should be. I’ll definitively be back for more.
The great summary assited me a lot! Saved the blog, extremely interesting categories everywhere that I read here! I really like the info, thank you.
A good friend of mine visits your blog quite often and recommended it to me to read too. The writing style is solid and the content is pertinent. Many thanks for the insight you provide the readers!
This nice summary encouraged me very much! Bookmarked the blog, extremely excellent topics just about everywhere that I see here! I appreciate the info, thank you.