PHP Basics Test Chamber

Conditional Statements

Conditional statements are used to create sections of code that execute based on predtermined conditions. Effectively, they allow your scripts to make decisions.

If Statements

The most general-purpose conditional statement. Any decision in your script can be defined with this statement, which is composed of an 'if', any number of optional 'else if' statements and a single optional 'else' statement.

88

Your number was in the range of 50 to 89.

You lose, please try again.

Switch Statement

Useful when you are checking a single variable for a particular set of known values. It is particularly useful with string variables and numbers.

216.73.216.122

I don't know where you are.

Ternary Operator

This is used when you need to set a variable based on a single condition being true or not. It is generally suggested that this statement should be avoided since you can do the same thing with an 'if' statement and it is easier to understand/debug.

You are outside Humber.