Blog Introductions

In this  blog contains tutorials about  HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials,  Examples, Source code,Learning,
Tips and Software development  services. Php Controls Flow Switch Statements | Php tutorials  Bestitworriors


Php Controls Flow Switch Statements



Php tutorials






Php Controls Flow Switch Statements | Php tutorials  Bestitworriors - Switch is used to execute one block from many blocks.In if-else part we see that we use in certein condation is true the execute the specifi if condation part if not true the execute the else part.In Switch we have many block but execute only one at one time if condation not match with any condation the execute the default part.Switch is same as if-else the work is same but little bit difference in code and structure but almost same woke.

Some Key Points of Switch


  1. Execute only block from many blocks
  2. It can save time then having multipule if-else
  3. Switch have same work like if-else
  4. Switch also execute specific condation match
  5. Inside switch case block is use to match the condation
  6. IF condation do not match then execute default code block
  7. Switch pass parameter to compare case block
  8. You can have multiple switch for specific criteria

Code



< ?php


$parameter = 10;
switch($parameter) {
case
1:
echo
"Your Parameter is".$parameter;
break;
case
2:
echo
"Your Parameter is".$parameter;
break;
case
3:
echo
"Your Parameter is".$parameter;
break;
case
4:
echo
"Your Parameter is".$parameter;
break;
case
5:
echo
"Your Parameter is".$parameter;
break;
case
6:
echo
"Your Parameter is".$parameter;
break;
case
7:
echo
"Your Parameter is".$parameter;
break;
case
8:
echo
"Your Parameter is".$parameter;
break;
case
9:
echo
"Your Parameter is".$parameter;
break;
case
10:
echo
"Your Parameter is".$parameter;
break;
default:
echo
"Your Parameter is greater then 10";
}
echo
"<br>";

$month = "january";
switch($month) {
case
"january":
echo
"Today month is ".$month;
break;
case
"feburary":
echo
"Today month is ".$month;
break;
case
"march":
echo
"Today month is ".$month;
break;
case
"april":
echo
"Today month is ".$month;
break;
case
"may":
echo
"Today month is ".$month;
break;
case
"june":
echo
"Today month is ".$month;
break;

default:
echo
"Your month do not match";
}


? >



OutPut

Your Parameter is 10
Today month is january







I hope You really enjoyed this blog . I try my best to make every thing is easy and helpfull to provide to public .You will get more blog about the Programing project and code . Thanks for visiting my blog if you have any querry related to this you can comment here i will try my best to response you back about Php Controls Flow Switch Statements | Php tutorials  Bestitworriors