PHP with MySQL Beoyond the Basics

Chapter 7: Working with Files and Directories

This chapter covers using PHP to navigate and change files and directories. A lot of these don't work on the school's servers.

Exericses

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.
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.
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.
Moving the File Pointer
Again, I really have no permissions on the school's servers, so here's what I was supposed to learn.
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.
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.
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.
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.