To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 07 January 2005 00:20, Jason Barnett wrote: > That was what I thought also. However just to add to the > confusion: I > think require'd files were evaluated no matter what back in > PHP4. Even > if they were part of a conditional. At least that's my > recollection of > it; I haven't used PHP4 since 4.3.2 ;) Back in about 4.0.2 or .3, that was the case; the current behaviour has been in place since at least 4.0.5. > Bottom line: I always require_once at the top of a file for any files > that I will require. No sense in doing anything else if the required > files aren't there. For conditionally including files include_once() > has always made the most sense to me. I'm not sure that's the best strategy: since include() will continue executing your script even if the file does not exist, you shouldn't use include() if anything which follows will fail in the absence of the (non-)included code. If the content of the other file is essential to the correct operation of your script, you should use require(), since that will terminate with a fatal error if the required file is not present. It makes sense to require() files in a conditional branch if *only* the code in that branch is dependent on the required file. If all (or at least enough) branches rely on the file, then requiring it at the top of the file is a sensible move. Whether you use the basic include()/require() or the _once versions depends on whether you want the code in the file to be executed each time the require/include is executed or not. For initialization of constants or parameter variables, the _once versions make sense; for code which contains substantive logic or output, it may not, especially if inside a loop. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@xxxxxxxxxxxxxx Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php