Re: [PHP] ?include?... another dumb question

2002-03-05 Thread Jason Wong

On Tuesday 05 March 2002 20:58, Team GotFusion wrote:
 I have people telling me that I MUST put the ?include? file before or
 inside the header of the .php file I am writing before a script is pulled
 into my file. I usually just put the ?include? whereever I need it on the
 page. Actually have it embedded in an IF statement, so that if the
 conditions are not met, the script is not run and there is no need to pull
 in the script.  It works fine

 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.

All this and more is covered in the manual.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
It is sweet to let the mind unbend on occasion.
-- Quintus Horatius Flaccus (Horace)
*/

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




RE: [PHP] ?include?... another dumb question

2002-03-05 Thread Cal Evans

Yes, this is acceptable.  Normally, include and require go at the top of the
page out of convention.  However, there is no requirement that they be
there.  Just be careful. it's an accepted convention because it's a good
idea.  Make sure you know what you are doing when you break with the
tradition.

=C=
*
* Cal Evans
* Journeyman Programmer
* Techno-Mage
* http://www.calevans.com
*


-Original Message-
From: Team GotFusion [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 05, 2002 6:59 AM
To: [EMAIL PROTECTED]
Subject: [PHP] ?include?... another dumb question


I have people telling me that I MUST put the ?include? file before or
inside the header of the .php file I am writing before a script is pulled
into my file. I usually just put the ?include? whereever I need it on the
page. Actually have it embedded in an IF statement, so that if the
conditions are not met, the script is not run and there is no need to pull
in the script.  It works fine

Is placing the include at the top absolutely required, good programming
convention or just preferred?

thanks, Tami
Team GotFusion


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




Re: [PHP] ?include?... another dumb question

2002-03-05 Thread Team GotFusion

Yep, ordered the manuals from Amazon.com... and they inadvertently shipped
the books to my mom-in-law ha ha. except that she's retired and
computers are still a mystery.
So, I am muddling through with my PHP dev. dictionary until I get to see my
relatives this weekend.
(cheesy smiley) Tami

Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED];
 On Tuesday 05 March 2002 20:58, Team GotFusion wrote:
  I have people telling me that I MUST put the ?include? file before or
  inside the header of the .php file I am writing before a script is
pulled
  into my file. I usually just put the ?include? whereever I need it on
the
  page. Actually have it embedded in an IF statement, so that if the
  conditions are not met, the script is not run and there is no need to
pull
  in the script.  It works fine
 
  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.

 All this and more is covered in the manual.

 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk

 /*
 It is sweet to let the mind unbend on occasion.
 -- Quintus Horatius Flaccus (Horace)
 */



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




Re: [PHP] ?include?... another dumb question

2002-03-05 Thread Erik Price


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





Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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