RE: [PHP] Include and require

From: Date: Thu, 03 May 2001 17:37:46 +0000
Subject: RE: [PHP] Include and require
Groups: php.general 
Request: Send a blank email to php-general+get-51303@lists.php.net to get a copy of this message
> According to the docu u should not require() files or > external code in loops > or u must use curly Bracket when used in if conditions. > > But everythink works fine. I require() successfully in for > loops, I can use > it in if..elseif..else constucts without curly brackets. > (only one line of > cause) > > So where is the difference between require() and include(). It depends on how you are using it. If you want what you are require()'ing to *vary* on each loop iteration, you must use include(). A require() is only executed once, during the initial parse of the file. An include() gets re-evaluated on each loop iteration, so you can vary the filename, etc. See http://www.php.net/manual/en/function.require.php for more. Kirk

« previous php.general (#51303) next »