Page 372 - Beginning PHP 5.3
P. 372

Part III: Using PHP in Practice
                          th { text-align: left; background-color: #999; }
                          th, td { padding: 0.4em; }
                         < /style >

                   This text editor has used many of the file - related functions described in the chapter, and has also
                 demonstrated some important concepts such as security and error handling. You can take many of these
                 concepts and apply them to other Web applications that you create.



                  Summary

                   In this chapter you learned how to work with files and explored PHP ’ s various file - handling functions.
                 You looked at:

                   ❑       How files and directories work, and the differences between file paths on UNIX - like servers and
                       Windows servers
                   ❑       Retrieving information on files using   file_exists() ,  filesize() ,  fileatime() ,
                         filectime() ,  filemtime() ,  basename() , and  dirname()
                   ❑     Using   fopen()  and  fclose()  to open and close files for reading and writing
                   ❑       Reading and writing to files using   fread() ,  fwrite() ,  fgetc() ,  feof() ,  fgets() ,
                         fgetcsv() ,  file() ,  file_get_contents() ,  file_put_contents() ,  fpassthru() ,
                         readfile() ,  fseek() ,  ftell() , and  rewind()
                   ❑       Setting file permissions with   chmod() , and checking permissions with  is_readable() ,
                       is_writable() , and  is_executable()
                   ❑       Copying files with   copy() , renaming and moving files with  rename() , and deleting files with
                         unlink()
                   ❑       Reading directories with   opendir() ,  closedir() ,  readdir() ,  rewinddir() , and  dir()
                   ❑       Manipulating directories with   chdir() ,  mkdir() , and  rmdir()
                   ❑       Testing for files and directories with   is_file()  and  is_dir()

                   Along the way you learned how to use recursion to move through a directory tree, and you also built a
                 simple text editor to illustrate many of the functions and concepts covered in the chapter.

                   Some functions rarely used in Web applications weren ’ t discussed. For a full list of PHP ’ s file and
                 directory functions, refer to the online PHP function list at:   http://www.php.net/manual/ref
                 .filesystem.php .














              334





                                                                                                      9/21/09   9:10:24 AM
          c11.indd   334                                                                              9/21/09   9:10:24 AM
          c11.indd   334
   367   368   369   370   371   372   373   374   375   376   377