RE: [PHP-DEV] Difference between include() and require()
| From: | Ford, Mike [LSS] | Date: | Wed, 20 Feb 2002 18:04:48 +0000 |
| Subject: | RE: [PHP-DEV] Difference between include() and require() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-80220@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Zeev Suraski [mailto:zeev@zend.com]
> Sent: 20 February 2002 17:41
>
> I guess you didn't understand the change - require() became
> like include(),
> not the other way around. That means you can selectively
> require() files,
> inside if() statements or inside functions, something you couldn't do
> before (beforehand, require()'d files were always processed).
Ahh, thanks! No, I don't think that's clear from the current manual entry -- the top line
of the include() says:
"The include() statement includes and evaluates the specified file."
which to me implied the former behaviour of require(), and nothing in the subsequent include()
description contradicts this. (And I didn't bother to follow the link to require(), which does
include the necessary explanation, because right at the top of include() is the sentence "The
two constructs are identical in every way except how they handle failure"!) Maybe the word
"conditionally" should be inserted to read "The {include()|require()} statement
conditionally includes..." and an explanation similar to the one in require() should be added
to include() to clarify what this actually means?
Thanks for the quick response, which was extremely helpful!
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211