I want to avoid duplicate function errors caused by including the same
file twice. So I thought I'd try C-style definitions, defining a
constant in each include file. To test it, I defined a constant
CONTROLS_INC in a control file. Then I tried out this simple code:
<?php
if (CONTROLS_INC) {echo "defined<br>"}
include("./controls.inc.php");
if (CONTROLS_INC) (echo "defined<br>"}
?>
That gave me two "defined" strings, even after I commented out the
include line, which puzzled me. So I reduced the code to
<?php echo CONTROLS_INC ?>
which gave the output "CONTROLS_INC"!!! So it seems that any arbitrary
text in php code is automatically defined as a constant, with its name
doubling as the value. OK, I worked around it by testing for a specific
value for CONTROLS_INC but this seems bizarre behaviour to me.
This is using PHP4, btw.