| 
 Posted by Jason Barnett on 01/07/05 02:20 
Jamie Alessio wrote: 
>>> Correct me if I am wrong, but includes (and/or requires) will get all of 
>>> the code in all of the cases regardless if the case is being processed. 
>>> 
> You're wrong. The include() and require() statements are only evaluated  
> when they are reached in your application code, so there is a big  
> difference between your two examples. In you use the second example the  
> code will only be included by PHP if the application logic enters the  
> case statement that contains the include() statement. Here's a quick  
> example to demonstrate this: 
>  
 
That was what I thought also.  However just to add to the confusion: I  
think require'd files were evaluated no matter what back in PHP4.  Even  
if they were part of a conditional.  At least that's my recollection of  
it; I haven't used PHP4 since 4.3.2 ;) 
 
Bottom line: I always require_once at the top of a file for any files  
that I will require.  No sense in doing anything else if the required  
files aren't there.  For conditionally including files include_once()  
has always made the most sense to me. 
 
 
--  
Teach a person to fish... 
 
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html 
PHP Manual: http://php.net/manual/ 
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2
 
[Back to original message] 
 |