relative paths and require()
Posted: Thu Sep 04, 2003 11:44 am
Problem: The production server and development server determine different current directories.
My development directory structure is like:
c:\inetpub\wwwroot\project\main\login.php
c:\inetpub\wwwroot\project\main\errorhandler.php
c:\inetpub\wwwroot\project\library\libone\dbconnect.php
login.php references dbconnect.php thus:
require_once('../library/libone/dbconnect.php');
in turn dbconnect.php references errorhandler.php thus:
require_once('../main/errorhandler.php');
presumably because it is still login.php that is executing, so the current directory is c:\inetpub\wwwroot\project\main.
All hunky-dory..................until I put in on the production server.
login.php references dbconnect.php ok as before.
But the reference in dbconnect.php ro errorhandler.php has to be changed to
require_once('../../main/errorhandler.php');
It seems that on the production server the current directory is determined by the source file that happens to contain the executing function, not the source file called in the first place by the web server.
All offer of clues, help and enlightenment greatfully accepted.
Simon
My development directory structure is like:
c:\inetpub\wwwroot\project\main\login.php
c:\inetpub\wwwroot\project\main\errorhandler.php
c:\inetpub\wwwroot\project\library\libone\dbconnect.php
login.php references dbconnect.php thus:
require_once('../library/libone/dbconnect.php');
in turn dbconnect.php references errorhandler.php thus:
require_once('../main/errorhandler.php');
presumably because it is still login.php that is executing, so the current directory is c:\inetpub\wwwroot\project\main.
All hunky-dory..................until I put in on the production server.
login.php references dbconnect.php ok as before.
But the reference in dbconnect.php ro errorhandler.php has to be changed to
require_once('../../main/errorhandler.php');
It seems that on the production server the current directory is determined by the source file that happens to contain the executing function, not the source file called in the first place by the web server.
All offer of clues, help and enlightenment greatfully accepted.
Simon