From the course: PHP Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Switch statements - PHP Tutorial
From the course: PHP Essential Training
Switch statements
- [Instructor] In this movie, we're going to be looking at a different kind of logical expression called switch statements. Switch statements are similar to if statements in that they control the flow through our application, but they're going to have a different syntax, some different rules to follow, and a couple of special gotchas that we want to make sure that we watch out for. First, let's look at the basic syntax. We're going to use the function name switch followed by an argument, and that argument's going to be of value. This is the value that we're going to be testing through each of a series of test cases. So then in our curly braces we're going to list off those test cases and each one is going to start with case and then a test value that we're going to test against value to see if they're equal and then a colon, and then a statement or series of statements that we want to execute. Then, following that will…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.