Below are examples using conditions in PHP.

(AKA Part 9 for Assignment 3)

You are legally allowed to drink in the United States!

Today I am feeling sad so I will watch a comfort show or movie.

My shirt today is green.

My explanation:

Conditions in PHP work by determining a result based on the value assigned to a variable. Once a value is assigned to a variable you can create a conditional function that evaluates the variable to see what conditions its value meets and determines a resulting output action based on such. There can be a number of set conditions in place so that if they cooridinate with the variable's value they will output a specific result, and if none of the conditions are met there can be a catch-all conditional output so at least something is outputted acknowledging that none of the set conditions were met.

Conditions control how code should be run based on specific conditional statements allowing for logic in PHP by using comparison and logic operators. They work together with operators that allow us to compare values, check conditions, and make conditions within our code.

1. if...else conditional statements execute some code if a condition is true and another code if that condition is false
2. if...elseif...else conditional statements execute different code for more than two conditions
3. switch/case conditional statements selects one of many blocks of code to be executed similarly to if...elseif...else statements. Switch/case conditional statements can be helpful for when you have many possible conditions to simplify the code in comparison to an if...elseif...else statement. These also use break statements in between conditions to prevent the code from running the next case automatically once an execution of a block has been finished, which also makes this faster than long if...elseif...else statements.