Summary

  • Files are a great place to store information across requests, and PHP gives you lots of ways to manipulate them. Older PHP scripts are unlikely to contain easier functions such as file_get_contents() and file_put_contents(), but these are very efficient functions and you should make use of them yourself.

  • Despite their flexibility, there is only so far files can take you - no matter how short the space between your fopen() s and fclose() s, it is still possible that two scripts may try to read from the same file at the same time.

  • File permissions can often be confusing, particularly on a server that does not belong to you. In this circumstance, make use of functions like is_readable() to make sure you have the right permissions before attempting any operations.

  • Thanks to the flexibility of PHP, you can treat HTTP and FTP connections as if they were local files, reading and writing freely.

 

Next chapter: Exercises >>

Previous chapter: Parsing a configuration file

Jump to:

 

Home: Table of Contents

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar