📄️ If Statements
Now we are going to look at control structures. Control structures are used to control the flow of your program. In this lesson, we'll look at the following control structures:
📄️ Conditionals & HTML Output
Sometimes you want to show or hide a UI element based on a condition. For example, you might want to show a button only if the user is logged in. Or you might want to show a message only if the user has not yet completed a certain task.
📄️ Comparison & Logical Operators
In this lesson, we will look at comparison and logical operators. These operators are used to compare values and to combine multiple conditions.
📄️ Conditionals In Loops & Break and Continue
We already looked at loops. Loops allow us to repeat a block of code as many times as we want. But what if we want to repeat a block of code only if a certain condition is met? So we already looked at conditionals in order to run a loop. We can also use conditionals inside a loop. Let's look at an example.
📄️ Challenge: Dynamic Job Listings Page
We are going to make the jobs listings page a bit more dynamic. I want to add 3 new features. If you would like, you can do this as a challenge.
📄️ Fizzbuzz Challenge
Fizzbuzz is a popular challenge for all types of programming languages. It is a simple challenge that tests your ability to use control structures. You will use loops and conditionals to solve this challenge.
📄️ Switch Statements
Switch statements are a way to execute different code based on different conditions or values. They are similar to if statements, but they are more concise and easier to read when there are many conditions to test. If you find yourself righting 5+ if statements in a row, you should consider using a switch statement instead.
📄️ Ternary Operator (? :)
The ternary operator is a shorthand way of writing an if...else statement and really comes in handy, especially when it comes to templates and HTML output.
📄️ Null Coalescing Operator
In the last lesson, we learned about the ternary operator. There is a newer operator as of PHP 7 that is similar to the ternary operator, but it is used to check if a value is null. It is called the null coalescing operator. This will be a quick video, but I wanted to just show you a quick example.
📄️ Names Challenge
Instructions