[thelist] managing php include dependencies?

Ivo evolt-thelist at sinchi.org
Wed Apr 11 11:36:11 CDT 2007

Hello all,

I am mystified by why a php app recently broke. The code changes
that lead up to the breakage were minor and unrelated.

The behavior I am seeing is that constants defined in an initial
configuration file are no longer defined in deeper includes. I echo
statements to the error_log  noting whether a constant defined in the configuration is
available in subsequent includes.

I have been using require_once & include_once liberaly to add the
configuration file wherever necessary. This means in some
code paths the include_once is called more than once but the echoed
statements in the configuration shows that it is parsed only once.

The log looks like this:

In status.html: constant not yet set TEST_CONSTANT is: TEST_CONSTANT
In configuration.php: set constant TEST_CONSTANT to: "**a test string**"
In status.html: set constant TEST_CONSTANT is:  "**a test string**"
In selector.php: constant TEST_CONSTANT is: **a test string**
In logger.php" constant TEST_CONSTANT is: TEST_CONSTANT

status.html, selector.php & logger.php use include_once('configuration.php')

The constant in question is not getting redefined (not explicitly
anyways). Same thing happens in all constants defined in configuration.php.

What could be causing this? Am I using include_once on this file too much?
A code path that hits include_once on the config only twice doesnt show
this problem. In the code path logged above all files include_once the

Thank you,


More information about the thelist mailing list