On Tue, 2004-02-03 at 17:04, Rob wrote:
Ive programmed with C/C++ for years and have recently started to dabble in
PHP. Ive written a multi-part script for a friend and Ive run into a
problem.
snip
Heres where the problem lies. Each component is in a separate file, and when
I run the script, I get an arror saying I cant re-define the classes.
Which makes me believe that the include_once() function is trying to include
the other components even though they are already included. So, does that
mean that include_once() only works right when it is used in the same file?
It wont recognise that an include was already included in another include?
Have I confused you yet? I am.
This is not an answer, but it is a solution. I don't ever rely on
include_once. If someone else uses my include files they may not use
include_once. Instead I use the old C/C++ trick of defines:
?php
if (!defined('SOME_INCLUDE')) {
define('SOME_INCLUDE', TRUE);
// Place code here
}
?
I use the following structure for creating unique constants to prevent
collisions:
{projectname}_{classname}( include ? _INC:)
A global class outside my projects:
_CLASS_NAME
The class FooBar in my Rule The World project:
RULE_THE_WORLD_FOO_BAR
The config include in my Rule The World project:
RULE_THE_WORLD_CONFIG_INC
--
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php