|
Posted by Schraalhans Keukenmeester on 05/31/07 14:04
At Wed, 30 May 2007 10:55:52 -0700, L. Berger let h(is|er) monkeys type:
> On May 30, 11:46 pm, "Gregor" <rmba...@comcast.net> wrote:
>> "L. Berger" <straightfwd...@gmail.com> wrote in message
>>
>> news:1180451838.251123.37150@d30g2000prg.googlegroups.com...
>> * * *
>>
>> > 1. Minimize require calls. (And use require instead of include or
>> > include_once or require_once).
>> > 2. Use an accelerator, such as eAccelerator. This compiles your code
>> > and basically boils it down to one include in most cases.
>>
>> * * *
>>
>> Could you explain these for me please, if you have the time?
>>
>> I can understand the obvious reasons to minimize require calls, but why do
>> you prefer, say, "require()" over "require_once()"? And why not use
>> "include()" for, say, a block of stand-alone text when you would rather see
>> it omitted than have the page not load?
>
>
> Sorry, it was not very clever of me to make a pronouncement without
> explanation. First, let's compare include and require, two
> differences:
>
> 1. Include will only include the file when conditionally appropriate,
> require will simply include it. In reality, especially when using an
> accelerator (more about that below), require simply becomes a part of
> your code. This is better than the PHP executable having to do some
> additional processing to figure out whether something was necessary to
> include or not. It's always there. When it is converted to bytecode,
> it's there.
>
Nonsense. Include and Require Both do as told unconditionally. You are
mistaken. Check it, try including a php class or func definition file
twice.
Conditional inclusion/requirement is happens with include_once
and require_once.
> 2. Include throws warnings, require throws errors -- which is an
> important consideration for production level code.
Yes, it is. I think no production code ought to spit out errors or
warnings which haven't been handled by the programmer. Do your own error
checking, use try/catch blocks, don't let PHP simply spew out default
errors. Which renders your second point moot as well imho.
Rgds
--
Schraalhans Keukenmeester - schraalhans@the.spamtrapexample.nl
[Remove the lowercase part of Spamtrap to send me a message]
"strcmp('apples','oranges') < 0"
Navigation:
[Reply to this message]
|