From the course: PHP with MySQL Essential Training: 1 The Basics
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Make page assets reusable
From the course: PHP with MySQL Essential Training: 1 The Basics
Make page assets reusable
- [Instructor] In the previous movie, we learned to use include and require. In this movie, we'll learn some additional techniques that can help you to use them better in your projects. So the first thing that I want to show you is how we can use variables in PHP to work with these included and required files. Specifically, I want to be able to set a page title on this page, $page_title, and I'm going to set it equal to let's just call it "Staff menu." So I'm setting this variable page title, what I want to show you is that that variable is available inside this file. It's exactly as if that php code were right in this spot, right at line four, all of the content of staff header were right there. That means that we have access to any variables that have been set. I just want to make sure that's clear to you. So here we go, let's put in a dash and let's do echo, $page_title. Now of course, we want to make sure that page title is set. So let's go up here to the very top, let's put in a…
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.