Re: <?include?>... another dumb question
| From: | Erik Price | Date: | Tue, 05 Mar 2002 15:55:38 +0000 |
| Subject: | Re: <?include?>... another dumb question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-87280@lists.php.net to get a copy of this message | ||
On Tuesday, March 5, 2002, at 08:08 AM, Jason Wong wrote:
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 ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.comIs 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.