Re: require or include

From: Date: Thu, 15 Nov 2001 19:25:11 +0000
Subject: Re: require or include
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74771@lists.php.net to get a copy of this message
It all depends on the purpose. With require, the script will die on the spot if the file is not found. Also, the code will always be included in the file.. so take this example: file.php: <? echo "Hello World!"; ?> requiretest.php: <? if (FALSE) {
       require('file.php');
} ?> The run script would be: <? if (FALSE) {
       echo "Hello World!";
} ?> Of course that code would never be executed, but the required file would be parsed and included as part of the file, whereas: includetest.php: <? if (FALSE) {
       include('file.php');
} ?> If the if() condition is not met, the file is not included at all.. so the parsed code would be: <? if (FALSE) { } ?> :) Mike Oosten, Sjoerd van wrote:
Hello list, I'm just wandering what's better, require or include. Greetings, ________________________________________ Sjoerd van Oosten Digitaal vormgever svoosten@esites.nl Datamex E-sites B.V. http://www.esites.nl Minervum 7368 Telefoon: (076) 5 730 730 4817 ZH BREDA Telefax: (076) 5 877 757 _______________________________________


« previous php.general (#74771) next »