Join Mark Niemann-Ross for an in-depth discussion in this video Teacher's guide: Overview of variables and built-in functions, part of Teach Kids Programming with PHP.
Just a reminder, this video is just for you, the teacher. I'll be talking pretty fast, and might even give away the challenge part of the chapter. If your student is watching, stop the video, and have them do something else for a minute. In this chapter, we're going to cover quite a few topics. We're going from a first look at actual PHP code, all the way to variables and commands. Your student may not have seriously looked at code before, at least not with an attempt to actually understand it.
They may have seen you writing code, but probably didn't realize what you were doing. Or, didn't have any idea how to understand what the code was meant to do. The program we'll be playing with, is extremely simple. Build a time string, stash it in a variable. Then, print a statement to a web page. It involves a handful of variables, a preset array, and one function with some arguments. That's enough for a quick swim, in the shallow end of the swimming pool. We'll be discussing the PHP documentation later in this chapter.
If you haven't looked at the online documentation lately, you might want to take a quick tour. PHP.net has been updated to a new look, and that might throw you off. You'll also want to take a refresher look at the documentation for the PHP date function, located here. In particular, look at the formatting options. Later, in this chapter, we'll describe the documentation page, as well as the formatting options for date. One note, I am not going to discuss the need for semicolons at the end of lines.
I'll mention that, in the next chapter. But, during this exercise, you'll want to check, for an accidental deletion. I've also used print, without explaining it's purpose, assuming the command is self-explanatory. Check with your student, to make sure this is a good assumption. You may be more familiar with echo. Don't worry, echo and print are identical. During the challenge segment, we'll be working with a second function, called string to upper. It's a simple function, but it's best to be prepared. Before you start the next video, use your PHP editor to open lunchMenu.php, and ALLCAPS_challenge.php, with lunchMenu.php, showing on top.
Arrange the http://lynda.com video, your PHP editor and the web browser, so, you can easily find them when needed. One final note, if you're typing, the student isn't learning. Let them control the keyboard. You're here to nudge them into the lesson, and help them get unstuck. Okay, when you're ready, let's get started, teaching a kid to program with PHP.
- Teacher's Guide: Introduces the concepts in the chapter and preps the adult on places where the student might get stuck
- Try It: Immediately engages the student, showing working code in action
- Check It Out: Encourages the adult and student to engage with and edit some existing code
- The Facts: A lecture for the student to watch
- Extend It: An exploration of expanded and extended concepts
- Challenge: A hands-on coding challenge for the student
- Solution: A step-by-step solution presented by the author
This course, in essence, acts as a lesson plan to help you teach PHP to a beginner. Its structured curriculum supports those who have a solid understanding of PHP, but don't necessarily know how to teach PHP effectively to kids.