Re: include and require
| From: | Eris Ristemena | Date: | Sun, 02 Jul 2000 16:18:24 +0000 |
| Subject: | Re: include and require | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-4367@lists.php.net to get a copy of this message | ||
OK , thanks for the answer.
The answer was just like in the manual but with neat illustration. :)
If that's the case, shouldn't we always use include() rather than require()
?? i mean (correct me if i'm wrong) you cann't use require() in else-if
statement or looping, and there's speed degradation if we use require(). So
why they still use this in PHP 4.0 ??
i think that's the question, is there any advantages or disadvantages of
require and include ?
thanks in advance
-eris
-----Original Message-----
From: scottrus@ipass.net <scottrus@ipass.net>
To: Eris Ristemena <ste94034@stttelkom.ac.id>
Cc: php-general@lists.php.net <php-general@lists.php.net>
Date: Sunday, July 02, 2000 8:22 PM
Subject: Re: [PHP] include and require
>heh. This time i read your question and will give you an answer :)
>Sorry about that last post which didn't answer your question.
>
>Take this example:
>
> $mything = 1;
> if ($mything) {
> include("myfile.inc");
> }
>
>In this example the file "myfile.inc" will ONLY be included if the
>var $mything = 1. So if we change $mything = 0 then the file
>"myfile.inc" will NOT be included.
>
>This second example uses require() instead of include():
>
> $mything = 0;
> if ($mything) {
> require("myfile.inc");
> }
>
>This time the file "myfile.inc" will be parsed (aka included) into the
>into the main script if $mything = 1 OR if $mything = 0. In the second
>example above if we change the require() back to an include() then
>"myfile.inc" would NOT be included because the if statment tests false.
>
>Hope this helps.
>
>-- Scott