3.1. Managing Files

The information you save on your hard drive is organized into files. Rather than storing files in one big file drawer, making them difficult to find, files are stored in many drawers, called directories or folders. The system of files and directories is called a file system. A file system is organized in a hierarchical structure, with a top level that is a single directory called root, such as c:\ on Windows or / on Linux. The root directory contains other directories, and each directory can contain other directories, and so on. The file system's structure can go down many levels.

A directory is a type of file that you use to organize other files. A directory contains a list of files and the information needed for the operating system to find those files. A directory can contain both files and other directories.

Files can be checked, copied, deleted, and renamed, among other things. Functions for performing these file-management tasks are described in the following sections. You also find out about functions that allow you to manage directories and discover what's inside them.

In this chapter, we cover the most useful functions for managing files, but more functions are available. When you need to perform an action on a file or directory, first check the online PHP documentation at www.php.net/manual/en to see whether an existing function does what you need ...

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.