Switch Statements -- PHP

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Parts of a switch statement

1. the switch keyword 2. a variable to check 3. a pair of curly braces { }.

No Difference

Is there a difference between the curly brace syntax or alternative syntax.

fallthrough

The ability In a switch statement to make multiple expressions, all of which have the same result by adding cases right after another without a break.

Syntax

The exact form that the computer expects .

Syntactic sugar

a computer science term that refers to syntax within a programming language that is designed to make things easier to read or to express, while alternative ways of expressing them exist.

Example of Fallthrough

case 1: case 2: case 3: echo '$i is somewhere between 1 and 3.'; break;

Alternative syntax

exists to provide syntactic sugar.

switch statement

provides efficiency and readability. Switches work like if statements, if a condition is true, it executes a block of code.

Syntax

refers to the spelling and grammar of a programming language.

switch statement

similar to an if / elif / else statement in that you can check multiple conditions.

What occurs when all cases return false

the default case gets executed.

switch statement

used when you have a series of if/elseif/else statements with multiple expressions that depend on the same value.


Ensembles d'études connexes

Chapter 4 - Ethics and Social Responsibility

View Set

Management Ch 11 - Managing Human Resource Systems

View Set

Combo with "DHN101-201: HUMAN NUTRITION AND WELLNESS (SPRING 2016) EXAM 1 CHP 1-4"

View Set