Re[2]: [PHP-DB] Curious if include_once will work better than include
| From: | Mikhail U. Petrov | Date: | Tue, 13 Apr 2004 18:06:39 +0000 |
| Subject: | Re[2]: [PHP-DB] Curious if include_once will work better than include | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-33862@lists.php.net to get a copy of this message | ||
Hi!
Sorry for my offtopic, but by the way,
what's the difference between include/include_once and
require/require_once?
Tuesday, April 13, 2004, 10:29:14 PM, Eric wrote:
>> Curious about "include_once" versus "include".
>>
>> All my connection stuff is in "conn.php3".
>>
>> I am planning on including it at the top of the page like this:
>> include_once "conn.php3";
>>
>> Now will that speed things up compared to just using a plain "include". I
>> call $connectionSDWIS(which is in the include) 5 different times?
EG> IMHO the 'speed' difference between include and include_once will be
EG> slight, probably with include_once being slower because of the overhead
EG> needed to keep track of which files have been included already. But this
EG> isn't really what the question is about. include and include_once will
EG> not magically optimize the code for you, but if you include the same file
EG> 20 times that will be more that has to be parsed needlessly, so if you
EG> can't keep track of your includes or if including a particular file more
EG> than once will alter the result, than use include_once. Another
EG> alternative is to use require() or require_once() to make sure that the
EG> file is included. Just my $.02,
EG> Eric
--
Best regards,
Mikhail U. Petrov
mailto:mikhail@begun.ru