Using 'require_once' on files in a directory above current
Posted: Sun Jan 28, 2007 5:28 pm
Basically I have a 'global_functions.php' file which has a bunch of handy little functions (including connecting to a specific database) which I use in heaps of different files so that if I change anything in it (eg. the password or name of the database), then I only have to change it once.
Anyways, if I have the following directory structure:
D:\Web_Pages\Objects\Results.php
Inside Results.php, I want to access 'global_functions.php' using require_once.
And yep, sure I can go 'require_once('d:/Web_Pages/global_functions.php') (or however it goes); but I want the name of the drive to be transparent so I dont have to change things when I move it onto a web server.
The directory structure would remain the same from so I wasn't sure if I could somehow just call 'localhost\global_functions.php' and this would work on any web server (assuming my home directory was set to D:\Web_Pages).
Thanks.
Anyways, if I have the following directory structure:
D:\Web_Pages\Objects\Results.php
Inside Results.php, I want to access 'global_functions.php' using require_once.
And yep, sure I can go 'require_once('d:/Web_Pages/global_functions.php') (or however it goes); but I want the name of the drive to be transparent so I dont have to change things when I move it onto a web server.
The directory structure would remain the same from so I wasn't sure if I could somehow just call 'localhost\global_functions.php' and this would work on any web server (assuming my home directory was set to D:\Web_Pages).
Thanks.