By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,642 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

How to prevent includes from attempting redefinitions

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a

"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.