Page 1 of 1

problem with including classes

Posted: Sat Jul 23, 2005 7:29 am
by Sema
In my app i am including two files with two classes eg. ClassPath.php and GlobalPaths.php. When i include these in my main doc. and try to use them, i get the following error:

Fatal error: Undefined class name 'globalpaths' in c:\documents and settings\sema\dokumenter\web\projekter\internt\newz.sema.dk\v3\public\main.php on line 65

The code is as follows...

Code: Select all

// Setup application class paths first
include $appServerRootDir.'/WEB-INF/classes/phpmvc/utils/ClassPath.php';

// Setup the app server paths
include $appServerRootDir.'/WEB-INF/GlobalPaths.php';
$globalPaths = GlobalPaths::getGlobalPaths();
$gPath = ClassPath::getClassPath($appServerRootDir, $globalPaths, $osType);
And i know that the files is included, (if i let them echo an output it prints that before the error). And if i place the code inside the includes it works, but it should work even if the code is outside the includes...

The code is run on a WinXP box, with PHP4...

Posted: Sat Jul 23, 2005 8:12 am
by shiznatix
what does line 64 look like? show us a lil more code

Posted: Sat Jul 23, 2005 8:15 am
by Sema
hmmm, found the problem,it seemes that it works if i give it paths like C:/Doc.... in stead of localhost, if i do that it works.. ;D why i dont know...

Posted: Sat Jul 23, 2005 8:20 am
by shiznatix
good work

Posted: Sat Jul 23, 2005 11:59 am
by Chris Corbyn
Sema wrote:hmmm, found the problem,it seemes that it works if i give it paths like C:/Doc.... in stead of localhost, if i do that it works.. ;D why i dont know...
Because PHP reads the filesystem of the computer it runs on. It doesn't read the HTTP server configuration so you must include the file from it's real location on the hard disk (or relative to the script)

../file.php would work too if the script calling it is in a subdirectory ;)