|
Chapter 13
PHP and Your Operating System
In This Chapter
Manipulating files
Running programs outside PHP
Transferring files from one machine to another
Sending e-mail and e-mail attachments
P
HP provides all the file-handling features that any full-featured language
offers. Using PHP, you can do anything you need to do with the informa-
tion on your system. You can manage your information in files — you can
create, copy, delete, find, move, and more. You can run any program that’s
on your computer, regardless of whether it’s a PHP program. You can transfer
files between computers. Or you can send information via e-mail. This chapter
gives you the information you need to use PHP to do pretty much anything
you can think of on your computer.
Managing Files
The information you save on your hard disk 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 directoriesor folders.The system of files
and directories is called a file system.A file system is organized in a hierarchi-
cal structure. A file system has 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 as many levels as you want.
A directory is a specific type of file that you use to organize other files. A direc-
torycontains 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.
PHP includes functions that allow you to open files and read what’s in them
or write information into them (as discussed in Chapter 12). Files also can be
checked, copied, deleted, and renamed, among other things. Functions for
|