From the course: PHP with MySQL Essential Training: 2 Build a CMS
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Use an option for conditional code
From the course: PHP with MySQL Essential Training: 2 Build a CMS
Use an option for conditional code
- [Instructor] In this movie, we will use an array of options with some of our functions to allow them to change their default behavior. Let me give you an example. Let's say we want to modify the behavior of our find all subjects function. We can pass in an argument to the function and then make the function, respond to that argument. A good way to do this is to pass in an array of options instead of a single argument. That way we can easily add other options by adding to the array, but the argument list does not grow and become hard to manage. So you can see here, I'm passing in options, I've got a default value, which is an empty array. So it is optional, we don't have to have anything sent in, but if we do, we can pass it an associate of array and we can respond to the values that are in that array. You can see here in my code, I'm checking the options to see if there is an option for visible. And if there is, I'm setting the variable visible to it, I'm also using the double…
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)
The public context5m 43s
-
(Locked)
Skip hidden subjects and pages3m 8s
-
(Locked)
Use an option for conditional code6m 34s
-
(Locked)
Insecure Direct Object Reference (IDOR)4m 20s
-
(Locked)
Protect page visibility6m 6s
-
(Locked)
Allow HTML in dynamic content6m 46s
-
(Locked)
Challenge: Preview content2m 11s
-
(Locked)
Solution: Preview content4m 12s
-
(Locked)
-
-
-
-