Re: [PHP-PEAR] FWD - Re: [PHP-NOTES] note 11898 added to pear.standards.including.php
[email protected] ((Stig Sæther Bakken)) 13 Mar 2001 23:04:29 +0100
| Newsgroups | php.notes,php.pear,php.pear.dev |
|---|---|
| Message-ID | <[email protected]> |
["Jesus M. Castagnetto" <[email protected]>] > I think that you may want to contribute your opinions > to the PEAR lists, instead of to the notes to the > manual. I am forwading this email to those lists too, > so people there can comment directly to you > ([email protected]) on your opinion. > > Will remove the note from the manual. > > --- [email protected] wrote: > > *_once-expressions have the disadvantage, that they > > can produce "ugly" code. > > > > Good code dosn't need to require anything more than > > once. In my opinion it is the same, as to shut off > > the configuration-option 'error_reporting' - you > > don't see if you include something more than once. > > > > So require() and include() should be used in my > > opinion for the "normal case", require_once() and > > include_once() should be used in the cases, when it > > dosn't work in another way. Hi Alexander, You're not including the file more than once, you're telling PHP that "I need the code that is in this file, please load it if you haven't already". The overhead is a simple hash lookup. Unless we want to expose the dependencies between packages to the user, (require|include)_once is the only consistent way. For example, if you have the "Foo" class, which again uses the "PEAR" class, the Foo.php file will require_once "PEAR.php". As long as this dependency is hidden to the user of the "Foo" class, he must always require_once. If you expose these inter-packcage/class dependencies to the user, there's a lot more hassle including the right files, especially if dependencies change. I'm verbing code here, it's called engphplish. - Stig -- Stig Sæther Bakken <[email protected]> Fast Search & Transfer ASA, Trondheim, Norway