answersLogoWhite

0


Best Answer

The case structure in PHP uses the following syntax:

switch($foo){

case 'bar':

doSomething();

break;

case 'blah':

doSomethingElse();

break;

default:

handleOtherCases();

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write coding php using switch case?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

How do you use a switch statement in GML?

Switch Statements are used to generate different outputs of code based on the value of an expression. Switch Statements work as follows:{randomNumber = floor(random(3))+1;switch(randomNumber) {case 1: { } break;case 2: { } break;case 3: { } break;default: { } break;}}This may seem confusing if you are new to GML, so I will give an in-depth explanation. The first line sets the variable randomNumber to a random number between 0 and 2, and adds it by 1 to make it a random number from 1-3. So far the only thing that has gone on in the code is to set a variable to either 1, 2, or 3. This is where the switch statement comes in.switch(randomNumber) {case 1: { } break;case 2: { } break;case 3: { } break;default: { } break;}this is the actual switch statement. You may be wondering what the case statements are for. case statements are always written inside switch statements and do nothing anywhere else. case statements activate when the expression in the switch statement is the same as the value that they are assigned to. Take a look at this switch statement:{rand = floor(random(3));switch(rand) {case 0: {show_message("The Random Value Was 0");} break;case 1: {show_message("The Random Value Was 1");} break;case 2: {show_message("The Random Value Was 2");} break;}} When the values assigned to the case statements are equal to the expression in the switch statement, the case statement will run the code contained in it's brackets. break statements order the switch statement to abort. The reason that you need break statements inside a switch statement is because it keeps the other cases from activating as well. (When one case statement activates, the others do as well.)A final briefing on switch statements is that they are not limited to variables. Take a look at this switch statement.{switch(obj_block.x > x) {case true: {show_message("The Block Is Ahead Of You.");} break;case false: {show_message("You Are Ahead Of The Block.");} break;}} This switch statement returns a true or false value, and the case statements operate accordingly.


How do you write the decimal 0.384333 using the bar notation?

................................................................._0.384333 using the bar notation = 0.3843(the bar should be placed above the repeated decimal. In this case, it should be above the 2nd 3 from the decimal point.


How do you write 0.074 as a percentage?

To write a decimal as a percentage move the decimal to spaces to the right and at a % sign. In this case it would be 7.4%


How do you write British pounds for 45000 pounds?

GBP 45000. When using computers it is important to use the ISO currency code (ISO 4217) which, in this case, is GBP. Some browsers cannot handle currency symbols, such as £, and will display it differently.


How do you write a decimal using a negative exponent?

When you have a negative exponent (for example 3^-3) you could make the recipricol of the number. So, this would be 1/3^3. Then all that you would have to do is solve for the exponent ( so in this case the answer would be 1/27)

Related questions

Discount program using java switch case?

This is not a question.


How do you break a loop in a switch case statement?

using break; statement


I am using Borland C compiler and making a program using switch cases while loading program I'm getting error that case bypasses initialization of a local variable case 4?

You cannot declare variables inside a case label. Declare them outside of the switch.


Write a program in C to check whether a given number is odd or even using switch statement?

#include<stdio.h> #include<conio.h> void main() { int n; printf("please enter number \n"); scanf("%d",n); switch(n%2) { case 0 : printf("even"); break; case 1 : case -1 : printf("odd"); } getch(); }


Writ a program in c to display day of the week using in switch case?

/* write a program to print Days of Week using switch-case structure */ #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("\n Enter Day of weak as Number 1 to 7 "); scanf("%d",&n); switch(n) { case 1: printf("\n MONDAY "); case 2: printf("\n TUESDAY"); case 3: printf("\n WEDNESDAY"); case 4: printf("\n THURSDAY"); case 5: printf("\n FRIDAY"); case 6: printf("\n SATURDAY"); case 7: printf("\n SUNDAY"); default : printf("\n no operation is required"); } getch(); }


Write an equivalence of switch statement and if statement?

switch(ch) { case '+': ....cout <<"arithmetic operator"; ....break; //<===break is a must /// <====================other cases . . default: // <=======else }


What is a serial coding?

Its the code on the top of the booklet in the case


How do you write algo for switch case?

input (alphabets) output(vowel or not vowel) operator(a,e,i,o,u) switch(alphabets) { case 'a' print"vowel" case'b' print"not vowel" case'e' print"vowel" case 'i' print"vowel" case 'o' print"vowel" case'u' print"vowel"


How do you write a program in c language to check the given charcater is vowel or not using switch case?

Code example:#define bTRUE 1 #define bFALSE 0 typedef int BOOL BOOL bIsItAVowel(char cLetter); int main(void) { char cMyTestLetter = 'a'; if(bIsItAVowel(cMyTestLetter)) { /* Yep, it's a vowel. */ } else { /* Nope, it's not. */ } return 0; } BOOL bIsItAVowel( char cLetter) { switch(cLetter) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': return bTRUE; break; default: return bFALSE; } }


Can you write a sentence using the word supreme?

The supreme court decided to throw out the case.


Write a java program using switch case to find zodiac signs?

Let's say you want a method which will determine if the given character is a vowel, consonant, or other (non-letter). // Will return a String representation of what the given character is: // "vowel" "consonant" or "other" public static final String getTypeOfChar(final char c) { // since chars are an integer data type in Java, we can switch on them switch(c) { case 'a': // all of these cases "fall through" to the next non-case statement case 'e': // if any of them matches case 'i': case 'o': case 'u': return "vowel"; case 'b': // again, all of these cases fall through case 'c': case 'd': case 'f': case 'g': case 'h': case 'j': case 'k': case 'l': case 'm': case 'n': case 'p': case 'q': case 'r': case 's': case 't': case 'v': case 'w': case 'x': case 'y': case 'z': return "consonant"; default: // if we have no matches yet, do this return "other"; } }


Do HTML coding got to be capitalized?

HTML tags are not case sensitive.