Yes, thank you Justin. I DID have a function exists which I somehow did not notice earlier.
Shaunak > -----Original Message----- > From: Justin Patrin [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 15, 2004 4:49 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Namespace issues > > > Shaunak Kashyap wrote: > > > Hi, > > > > Facts: > > > > 1. I have the following four scripts: a.php, b.php, c.php and d.php > > 2. a.php defines a function named foo. > > 3. b.php includes c.php > > 4. c.php defines a function named foo > > > > > > Case I: d.php looks like this: > > > > <code> > > include "b.php"; > > include "a.php"; > > </code> > > > > This causes a fatal error that says that foo cannot be redeclared. > > > > Case II: I change d.php to look like this: > > > > <code> > > include "a.php"; > > include "b.php"; > > </code> > > > > This does NOT cause the same fatal error. When I called foo > from d.php, it > > called the foo defined in a.php > > > > > > Can anyone explain why a fatal error wasnt caused in Case II? I > am using PHP > > version 4.2.3 > > > > Thank you, > > > > Shaunak Kashyap > > Perhaps you have a function_exists() (or similar) call wrapping the > declaration of foo() in c.php? > > If you're using this same function in multiple files and it's the same > funciton, you ought to put it in its own file and require_once() the > file in the places where you need it. That way, you don't get this > problem. You could also wrap all of the declarations in > funciton_exists() calls. > > -- > paperCrane <Justin Patrin> > > -- > 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