inclusive includes problem
Moderator: General Moderators
-
sportsdude11751
- Forum Newbie
- Posts: 4
- Joined: Sun Jul 15, 2007 11:39 am
inclusive includes problem
I'm having a few problems with some include() statements in my php. I have to include some scripts that are in a seperate file, so I use the ".." to go back a directory (to my main directory) so something like this include("../standAlones/openHalf.php"); However, that script (openHalf.php) includes something from another file, and thats where i get my errors. I tried using set_include_path, but i'm not to sure on how it works. If you have any ideas on how to approach this different, or know of a fix, or have an example of set_include_path, i would greatly appreciate it! -Thanks
relative paths like ../standAlones/openHalf.php are always relative to the current working directory (cwd).
Php sets the cwd to the path of the "main" script. An include() or require() doesn't change the cwd. In case of doubt print the cwd via echo 'cwd: ', getcwd();
If you want the current script file's location as "anchor" use e.g. __FILE__ and dirname()
Php sets the cwd to the path of the "main" script. An include() or require() doesn't change the cwd. In case of doubt print the cwd via echo 'cwd: ', getcwd();
If you want the current script file's location as "anchor" use e.g. __FILE__ and dirname()
-
sportsdude11751
- Forum Newbie
- Posts: 4
- Joined: Sun Jul 15, 2007 11:39 am
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
set_include_path() is fairly explanatory. If you look at Example 1829 on the linked page, it gives a more complex use.