12.5. Fundamentals

In this section, you learn some fundamentals and principles that you should apply to PEAR packages that you plan to release.

12.5.1. When and How to Include Files

You can save yourself from some potential trouble by including files wisely. You should follow three principles on including files:

  1. Only use include_once or require_once. Rule number one is to always use require_once or include_once to include PEAR code. If you use require, your script will likely die because of redefinition errors (or it will die sometime in the future).

  2. Determine the correlation between class and file names. PEAR uses the one-class-per-file principle, with the intention that it should be trivial to generate the required file name from the class name. ...

Get PHP 5 Power Programming 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.