> The way I understand it (maybe you know something I don't?) > require/include_once only prevent an included file from being included > MORE than one time, hence the character string _once tacked onto the end > of include() and require(). > > It does NOT however include a file only when it's needed, it merely > includes it once.
Yes, and this can be used to help reduce overhead. For instance, if you require_once() a script which connects to a database in every function you write which uses a database, you will never connect to the database unless you use a function which needs it. Same concept applies to other functions, etc. you can write. PHP never "magically" decides what you need. But it does ensure that things which require system resources (whether they be variables or a connection to a database or classes) are never included unless the function they are require_once()d in is called (or the branch of the if statement or whatever). This can be used to save system resources: 1. If no function calling a require_once() is called persistent resources are never used. (Persistent in the sense that they take up resources for a scripts execution once called) 2. If a function calling a require_once() is called persistent resources persist -- i.e. you don't need to reconnect to a database (which takes more resources) or run an if (!($foo)) { $foo = 'something'; } (which saves coding time -- and makes code easier to read). 3. If a function calling a require_once() is never called the script will never be parsed (and resources used). Perhaps I was not 100% clear in my original post, but require_once()s /can/ be used to not eat massive system resources. -Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php