Newbie question about include and require...

From: Date: Thu, 02 Mar 2000 18:31:01 +0000
Subject: Newbie question about include and require...
Groups: php.version4 
Request: Send a blank email to php-version4+get-11373@lists.php.net to get a copy of this message
Hello again, I have an include file (application.php, pasted in below) that I'm adding to each page on my site using the require function. This file also requires other files in the same directory as itself. I'll call that directory A. Requiring application.php from any php files in directory A works just fine as expected. If I have a subdirectory of directory A (directory B), I can't find an elegant way to include application.php. When I try using require("../application.php"), it correctly finds application.php from directory A but execution fails when application.php tries to require another file. PHP doesn't correctly resolve the path to the required files since its executing from a subdirectory (which makes some sense). I've tried hard-coding the path to the files that I require in application.php, but that doesn't seem to work. Is there an easy way to tell PHP to look in the same directory as the file that is requiring other files (ie: directory A). Here is the code for application.php: <? // Display the offline message if we are offline $Offline = 0; if ($Offline) { require("unavailable.php"); exit(); } // Initialize the security parameters if the user isn't already logged in session_name("constructor"); session_start(); // Setup the global variables and database object require("application_globals.php"); require("application_db.php"); if (!session_is_registered("LoggedIn")) { session_register("LoggedIn"); session_register("Name"); session_register("ID"); session_register("Email"); session_register("Tech"); session_register("Pub"); session_register("Admin"); session_register("InvalidLogin"); session_register("CookieFailed"); $InvalidLogin = 0; $LoggedIn = 0; $CookieFailed = 0; } // If they sucessfully logged in, then run the login routine if (isset($GoGoGadgetLogin) && isset($constructor)) require("application_login_routine.php"); else if (isset($GoGoGadgetLogin) && !isset($constructor)) $CookieFailed = 1; // Run the log-in script if ($LoggedIn == 0) { require("login.php"); exit(); } ?> Thanks! -- Ryan Robertson Palm Development Support

« previous php.version4 (#11373) next »