470,855 Members | 1,269 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

How to prevent includes from attempting redefinitions

I import library routines using include(...);

However, importing library routines that themselves use other library routines
easily leads to repeated declarations - which give errors of the form:

``Fatal error: Cannot redeclare method_name() (previously declared in
/usr/local/home/httpd/vhtdocs/timtyler/php/table_highlight_border.inc.php:2)
in /usr/local/home/httpd/vhtdocs/timtyler/php/table_highlight_border.inc.php
on line 11''

Should I try setting flags - and doing things conditionally?

What is the best approach for working around this issue?
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #1
3 2050
Tim Tyler wrote:
I import library routines using include(...);

However, importing library routines that themselves use other library routines
easily leads to repeated declarations - which give errors of the form:

``Fatal error: Cannot redeclare method_name() (previously declared in
/usr/local/home/httpd/vhtdocs/timtyler/php/table_highlight_border.inc.php:2)
in /usr/local/home/httpd/vhtdocs/timtyler/php/table_highlight_border.inc.php
on line 11''

Should I try setting flags - and doing things conditionally?

What is the best approach for working around this issue?

Try include_once() that way PHP will keep track of if it has included
the file already and won't try again.

--
John Downey
http://delusive.dyn.ee
http://sage.dev.box.sk
http://blacksun.box.sk

Jul 17 '05 #2
John Downey <bl**@doesntexist.com> wrote or quoted:
Tim Tyler wrote:

What is the best approach for working around this issue?


Try include_once() that way PHP will keep track of if it has included
the file already and won't try again.


Thanks.
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #3

"Tim Tyler" <ti*@tt1lock.org> wrote in message news:Hn********@bath.ac.uk...
I import library routines using include(...);

However, importing library routines that themselves use other library routines easily leads to repeated declarations - which give errors of the form:

``Fatal error: Cannot redeclare method_name() (previously declared in
/usr/local/home/httpd/vhtdocs/timtyler/php/table_highlight_border.inc.php:2) in /usr/local/home/httpd/vhtdocs/timtyler/php/table_highlight_border.inc.php on line 11''

Should I try setting flags - and doing things conditionally?

What is the best approach for working around this issue?
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.


You can use include_once() or else perform your includes from within the
parent calling script (as opposed to having one include inside another
included function/script), place what you want to include at the very
begining of your script
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Just1Coder | last post: by
14 posts views Thread by Ludwig77 | last post: by
3 posts views Thread by GarryJones | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.