require_once() ... gone mad? !
I have been struggling with this all afternoon and I'm, well lats just
say, very pissed off ...
I have a require once in a file. I am passing the fully qualified (i.e.
absolute pathname) to a file that exists on my machine (I'm looking ath
the file now).
I am evaluating the pathname like this (see below)
Contents of app_config.php
===========================
<?php
function fix_trailing_char($pathname){
$fixedname = $pathname[strlen($pathname)-1] == "/" ? $pathname :
$pathname. "/" ;
return $fixedname;
}
define("DOC_ROOT", fix_trailing_char(dirname($_SERVER["DOCUMENT_ROOT"])));
define("CLASS_ROOT", DOC_ROOT . "classes/");
define("CONFIG_ROOT", DOC_ROOT . "global/");
?>
The file below causes errors
==============================
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "global/app_config.php");
require_once(CLASS_ROOT. "common/somefile.php");
?>
I get this error:
Warning:
require_once(C:/workdir/src/website/classes/common/package.exceptions.errors.php)
[function.require-once]: failed to open stream: No such file or
directory in C:\workdir\src\website\www\classes\auth\MyControll er.php on
line 11
Fatal error: require_once() [function.require]: Failed opening required
'C:/workdir/src/website/classes/common/package.exceptions.errors.php'
(include_path='.;C:\workdir\src\website\www\;C:\wo rkdir\src\website\www\classes;C:\workdir\src\websi te\www\classes\mystuff')
in C:\workdir\src\website\www\classes\auth\MyControll er.php on line 11
For the cynics out there who may think the file does not exist:
C:\workdir\src\website\www\classes\common>dir pack*
Volume in drive C has no label.
Volume Serial Number is 7C79-29A1
Directory of C:\workdir\src\website\www\classes\common
12/05/2008 15:59 5,885 package.exceptions.errors.php
12/05/2008 16:02 364 package.exceptions.errors.test.php
2 File(s) 6,249 bytes
0 Dir(s) 6,603,599,872 bytes free
Incidentally, is there any way for me to change the include_path in a
script ?
Looking for some answers quickly before I throw my computer out of the
window (or better still go back to C++ where everything seems to make so
much more sense)
|