On Tuesday, March 5, 2002, at 08:08  AM, Jason Wong wrote:

>> Is placing the include at the top absolutely required, good programming
>> convention or just preferred?
> Simply put, you can place them wherever you want. Obviously if your 
> include
> file defines certain variables then common sense dictates that you 
> include it
> before you refer to those variables.

I was using a similar technique for some time, where I just "included" a 
file that contained whatever code I needed, in the place where it was 
appropriate.  It ended up getting hard to handle, though, because 
sometimes I'd want access to an includefile's functions but the 
includefile contained HTML outside of PHP or perhaps an echo statement 
or something, and I had a header() function or cookie action somewhere 
below this (these things are invalid once HTML is first output).

I eventually switched to a setup where my includefiles may contain 
variables or functions that I wish to use, but nothing that could output 
any HTML, so that I can include them wherever I want without worrying 
about it.  I just call the function or use the variable in the 
"decision" logic of my scripts now.  It's conceptually cleaner.



Erik Price
Web Developer Temp
Media Lab, H.H. Brown

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to