Hi,
I've come across something that is really puzzling me. I have a site with a number of user-defined functions stored across several scripts, i.e. database functions, date/time functions, etc., particular to my site. I have a script init.php that includes each of these files at the beginning of each script, i.e.
init.php:
<?php
include_once("functionlib/db_functions.php");
include_once("functionlib/date_functions.php");
... etc.
?>
I call init.php at the beginning of each page, as
index.php, or any other page:
<?php
include("init.php");
...content
?>
I then check to see if the functions in db_functions.php were created successfully, through function_exist. PHP says none of them exist. Oddly, when I have the
index.php, or any other page:
<?php
include_once("functionlib/db_functions.php"), ...
...content
?>
commands at the start of any page, PHP says that the functions exist. So it appears that nesting an include() statement inside another include()-ed file causes scope issues with regard to user-defined functions. Is there something that I'm doing wrong, or is this just a feature of PHP I have to work around?
Thanks, Matt