Guide to PHP and MySQL (University at Buffalo Version)
Chapter 4: Using Conditionals
PHP conditionals provide a way to execute a statements or statements based on whether some condtion is met or not met.
PHP if/else Conditional
The if statement allows you to test whether some condition is true or false. If the result of the test is true then the statement(s) between the first { and } are executed. If the result is false the then statement(s) between the else { and } are executed. For example:
PHP switch Conditional
The switch statement allows you to test whether some condition is met or not met. If the parzmeter that is passed to the switch statement is equal to any of the case statements then the statement(s) between that case: statement and break statement are executed. If the parameter does not match any of the case statements then the statements after the default: statement(s) are executed. For example: