Using include_once() and include_path to Manage Larger Projects

As your projects grow larger in scope and you find yourself including more and more files, keeping track of your work can be difficult. You can recover control by organizing code into libraries and organizing your libraries into packages.

As you work on a project, you should look for opportunities to create libraries that might also be useful for other projects. Try to create code that is as independent of your wider application as possible. The most reusable classes or functions will require data and perform tasks without relying on global variables. As you add to your stock of code, you can organize it using the file system itself. Let’s imagine a programmer named Mary Jones. ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.