problem with including classes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Sema
Forum Commoner
Posts: 34
Joined: Fri Sep 03, 2004 12:43 pm
Location: Aalborg, Denmark

problem with including classes

Post 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...
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

what does line 64 look like? show us a lil more code
User avatar
Sema
Forum Commoner
Posts: 34
Joined: Fri Sep 03, 2004 12:43 pm
Location: Aalborg, Denmark

Post 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...
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

good work
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
Post Reply