Page 1 of 1

redecalre or cicular unit erros

Posted: Wed Mar 05, 2003 7:07 am
by mzfp2
erros that look something like this

Fatal error: Cannot redeclare write() in ......../...

are extremely annoying, is there no one fix solution to resolve circular references rather than having to maze thru all the code files to see whats calling what?!

M

Posted: Wed Mar 05, 2003 7:13 am
by twigletmac
If you use include_once() or require_once() instead of include() or require() for including function or class files then you should avoid the redeclare errors because the file won't be included if it has been already.

Mac

Posted: Wed Mar 05, 2003 8:14 am
by BDKR
Twig, as allways(!), is correct. However, this may be indicative of a greater problem. That being that there is no clear place in your projects, scripts, webpages where included or required files are placed. I like to place all files that will be included in a script that is part of say a larger website in a configuration file. If I have a need for functionality that is common only to one script or page, then I include it at the top.

Just some ideas, but if you standardized on a way of doing things it'll most likely make you a more effecient coder.

Cheers,
BDKR

Posted: Wed Mar 05, 2003 12:46 pm
by mzfp2
so are you saying i shouldnt use includes? currentl my websites has its functionality divided into modules or unit files, each module may output by parsing templates, but i cam see there is a confusion as to what need whats, but im only a newbie :) !

Posted: Wed Mar 05, 2003 2:25 pm
by BDKR
mzfp2 wrote:so are you saying i shouldnt use includes?
Not at all! Like I said, just standardize how and when you include or require files. Do the same way all the time.

Cheers,
BDKR