O'Reilly logo

Sams Teach Yourself PHP, MySQL® and Apache All in One, Second Edition by Julie C. Meloni

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. Working with Files and Directories

Testing for the existence of files, plus reading to them and writing to from them, are important features of any rich programming language. PHP is no exception, as it provides you with functions that make these processes fairly straightforward. In this chapter, you will learn

  • How to include other files in your documents

  • How to test for the existence of files and directories

  • How to open a file before working with it

  • How to read data from files

  • How to write or append to a file

  • How to lock a file

  • How to work with directories

Including Files with include()

The include() statement enables you to incorporate other files (usually other PHP scripts) into your PHP documents. PHP code in these included files will then ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required