From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
How PHP makes decisions - PHP Tutorial
From the course: PHP for Web Designers
How PHP makes decisions
In this chapter, we're going to see how to change the content of web pages, depending on specific conditions. For example, you might want to show different content depending on which day or month it is. Or if a person is logged in. Or if a form has been submitted. Before doing so, we need to look at how PHP makes decisions. If you're familiar with conditional statements in JavaScript, you'll find that PHP works almost identically. Even if you're not familiar with JavaScript, you'll be glad to know that decision making is based on human language. The basic structure of a conditional statement in PHP looks like this. The keyword if is followed by a condition wrapped in parentheses. Conditions are often based on comparisons, such as whether two values are equal, or one is greater than the other. If that condition is true, all the code between the pair of curly braces will be executed. If the condition is not true, PHP skips over all the code inside the curly braces, and it carries on…
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.
Contents
-
-
-
-
-
(Locked)
How PHP makes decisions3m 30s
-
(Locked)
Changing output depending on the current time9m 1s
-
(Locked)
Adjusting the server's time zone8m 57s
-
(Locked)
Displaying an up-to-date copyright notice6m 18s
-
(Locked)
Challenge: Displaying an image of the month2m 15s
-
(Locked)
Solution: Displaying an image of the month5m 12s
-
(Locked)
Understanding what PHP treats as true and false2m 57s
-
(Locked)
-
-
-
-
-