RE: [PHP] Require() vs Include()
| From: | Duke Normandin | Date: | Tue, 14 Nov 2000 18:21:24 +0000 |
| Subject: | RE: [PHP] Require() vs Include() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-25217@lists.php.net to get a copy of this message | ||
On 14 Nov 00 at 11:32, php-general-digest-help@lists wrote:
>Maxim Maletsky writes:
>> OK, then.
>>
>> what is the reason require() exists?
>>
>>
>> If it works the exactly same way as include() except that include can be
>> more flexible why would we use require() then?
>>
>> Any performance issues?
>> usability?
>> security?
>>
>> Thanks Lawrence,
>
>In PHP 3, it was quite a bit faster than include(). There were other
>semantic differences between the two as well, such as return values
>etc. Performance appears to now be pretty much the same; you can
>return values with include() now, and so forth and so on.
>
>BTW, require() will fail in a completely different way from include()
>when it can't find the target file. include() will simply return a
>false value, whereas require() will spit out a great big 'Fatal error'
>and halt script execution.
Is my paraphrasing correct?
require() is "absolute" -- so don't use it in a conditional statement
because it makes no sense (to me anyway)
require() is "absolute" -- make sure that what you "require" exists where
it's suppose to be, otherwise the script fails "hard".
include() is *not* absolute -- use it in a conditional
include() failures do so "softly" - returns garbage, e.g.
Up to php4.0.1 require() had the edge on speed -- none to very litle with
php4.0.2+.
-duke
Calgary,Alberta, Canada