Re: require statement

From: Date: Wed, 12 Jul 2000 22:12:52 +0000
Subject: Re: require statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-6309@lists.php.net to get a copy of this message
In article <20000711101348.27797.qmail@musone.chek.com>, php3mario@lovemail.com ("mario mario") wrote: > I'm using the require() function to include an external php file ... > > The theory was if you use require() statement, it will executed event if the statement never been met.. > > I try that in NT (maybe this is the reason why or not ?).. and the theory has not been proved .. > > any comment ? The code will be executed only if the logic leads there: EG: for ($i = 0; $i < 10; $i++){ require 'foo.inc'; } The code in foo.inc is going to be pasted directly in there, once, and only once, when that line is hit, but not before. Contrast this with: for ($i = 0; $i < 10; $i++){ include 'foo.inc'; } which will load foo.inc each and every time in the loop. Major difference: If foo.inc refers to $i, it will always use 0 in the first case, but will be 0, 1, 2, 3, ... 9 in the second case. I don't think require gets "pre-loaded" before PHP even gets to the line that does it or anything like that though, which seems to be what you were describing. Hope that makes sense. -- Richard Lynch | If this was worth $$$ to you, buy a CD US Customer Support Director | from one of the artists listed here: Zend Technologies USA | http://www.L-I-E.com/artists.htm http://www.zend.com | (this has nothing to do with Zend, duh!)

« previous php.general (#6309) next »