Well, the way I've read it is that if you use require within control
structures then all files are included, regardless of whether the script
exits before it reaches its next if...elseif...else or case statement. With
include that does not happen. So the general rule of thumb would be to use
require() if you are not using it within these control structures, and use
include() if you actually do need to use include statements in your control
structures. Now, that said, I'm really not sure if that is true for the
require_once and include_once functions also. You might want to look into
that. Hope this helps a little.

-- Darwin

> -----Original Message-----
> From: Kerry Kobashi [mailto:kkobashi@;thegrid.net]
> Sent: Friday, November 01, 2002 1:36 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Require_once problem
>
>
> Whats the difference between require_once and include_once?
>
> I been running into a problem, perhaps someone can help.
>
> I require_once in a Pear database extension. Inside that pear database
> extension
> is a require_once("pear.php") and a require_once("db.php")
>
> This file, Thomas Voxs' DbPage.php file, gets require_once inside yet
> another
> file (my file).
>
> The problem is, my file brings in many require_once file's, some of which
> require_once(db.php) inside of it. All I get redefinition
> problems all over
> the place.
>
> It appears to me that require_once doesn't work as advertised? For if it
> did,
> there should never be redefinition problems.
>
> Why didn't all PHP code do like we do in C/C++ with
> #define BLAH
> if !defined(BLAH)
> {
>    your code here.
> }
>
> I realize the #define trick works as I used it in my own PHP code... but
> when
> the basic PHP core files don't have this in them, it sort of  makes
> require_once
> and include_once hacks! (that don't work)
>
> Any ideas suggestions?
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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

Reply via email to