PHP with MySQL Beyond the Basics

This is a Lynda.com tutorial series focusing on more advanced concepts with PHP, MySQL, and object-oriented programming. Again, because of server issues, all the exercises are hosted on the school's servers.

The exercises on this page are displayed in reverse order of completion.

Posted Exercises

Chapter 14

Simple Templating
The exercise covers three ways of creating a template.

Chapter 13

Using Headers
Since we can't send mail through the school's servers, I tried to include the important information from the exercise.
Using PHPMailer
The exercise outlines how to send mail using PHPMailer, both with sendmail and using an SMTP server.
Building Notifiction for New Comments
The exercise reinforces the previous exercises and introduces heredoc format.

Chapter 8

Moving Uploaded Files
For fairly obvious reasons, the school doesn't allow file uploads through forms. As such, the page simply outlines what the exercise teaches, instead of a demonstration.

Chapter 7

Viewing Directory Content
The page displays the contents of the Chapter-7 directory. The first part uses a simple while statement with readdir() and the second part uses a foreach with scandir() returning an array.
Working with Directories
The exercise covers getting the current directory, changing directories, and creating and removing directories. Those final two don't work, again because of permissions.
Examining File Details
The exercise covered viewing information about a file including its size and the last time it was changed and accessed. It also delved into using pathinfo and touch. The former worked, the latter didn't, so it isn't included.
Reading Files
The exercise covered how to read in files by specifying number of bytes, using filesize() to get the entire lenght of the file, using file_get_contents() to get the entire file, and using feof() and fgets() to output each line until the end of the file is reached.
Moving the File Pointer
Again, I really have no permissions on the school's servers, so here's what I was supposed to learn.
Deleting Files
This exercise focuses on opening/creating files, writing to files, and using file_put_contents(). But, since I don't have write permissions, only one of these things worked, and I had to manually create the file.
PHP Permissions
Since I'm doing this on the school's servers, I pretty much only have the ability to read. Because of that, I'm including two files, the explanation of how it works and the exercise itself.
File System Basics
This exercise covers using a few magic constants in regards to files and directories as well as how to determine if something is a file or a directory.

Chapter 4

Comparing Objects
The exercise displays the way to use comparison operators and identity operators. The comparison operator will return true in comparing objects that are references and between instances with matting references. The identiy operator will return true only between references. Both return false when comparing instances with different attributes.
Cloning Objects
The exercise covers creating references to objects vs. cloning objects. It also covers using the __clone method.
Using Constructors and Destructors
Constructors are used to perform functions when the class is first created. Destructors are used to perform functions as the class is being destroyed. The page displays some basic data that's been created through the __constructor method.
Referencing the Parent Class
Use self:: to reference the same class; ClassName:: to specify a parent; parent:: to use the parent without its name. The page displays various ways of using references to the parent class.
Working with the Static Modifier
The static keyword allows the item to exist even if there is no instance of the class. The page displays the information in the class using the Class::attribute syntax. With static methods, you can't use $this, so you have to use the double-dot notation plus a dollar sign. Static methods are shared throughout the inheritance tree. Defined once, called everwhere.
Using Setters and Getters
The exercise covers making setter and getter methods.
Setting Access Modifiers
This exercise covers using the Public, Private, and Protected keywords. Items with Public access can be called from anywhere, this is the default access type; items with Private access can only be called within the class; items with protected access can be called by the class and any of its subclasses.
Understanding Class Inheritance
The page displays the properties of two classes, Car and CompactCar. Their properties are the same because CompactCar extends Car.

Chapter 3

Defining Class Properties
Simple calling functions and creating and setting instance variables. The exercise also included getting all the class vairables and using property_exists().
Referencing an Instance
The page displays code that called $this to reference the instance. $this was utilized in the get_class() function as well as in the hello() method, which simply calls the say_hello() method.
Instantiating a Class
The page displays using get_class, is_a, and calling methods.
Defining Class Methods
The page simply displays the results of get_class_metohds and method_exists.
Defining Classes
The class created has no information, it's just been created. The page displays the results of class_exists() on a class that has been created and one that hasn't. The other method learned was get_declared_classes(), which shows all declared classes.

Chapter 2

Using References as Function Return Values
The page displays various ways of changing the value of referenced variables.
Using References as Function Arguments
The page displays the results of using references in function arguments.
Making a Reference Statement
The page displays the difference between a variable assignment and a variable reference.
Establishing Global and Static Variable Scope
The page displays three examples dealing with global, local, and static variables.
Setting Server and Request Variables
The page displays a list of server variables and their values.
Formatting Dates and Times: Strings and SQL
This exercises teaches how to use the strftime function to format dates. The first part of the exercise has the date set to January 31, 2011 to illustrate how leading zeros work and how to get rid of them. The second part of the exercise simply shows the format for MySQL dates.
Building Dates and Times: Epoch/Unix
The page displays using time(), mktime(), and strtotime(), all of which display the Unix timestamp.
Applying More Array Functions
The page displays using array_shift, array_unshift, array_pop, and array_push.
Variable Variables Part 1 | Part 2
Part 1 uses some very simple examples of using a dynamic variable. Part 2 shows a more practical application where student names are found using their seat assignments.