View Full Version : include_path and Windows
Is it possible to set the php.ini "include_path" such that includes are relative to the current directory?
Spookster
05-24-2003, 10:12 AM
I'm not sure if I understand what you are wanting to do. PHP will look in the current directory for the include file and will look at the directory specified in the include path.
Never mind. Apparently I'm stoned.
What I meant was the following, which now seems to work. Go figure.
What I was doing:
<?php
include("header.htm");
?>
What I wanted:
<?php
include("./include/header.htm");
?>
I was doing this for testing purposes.
Spookster
05-27-2003, 09:03 PM
I'm still confused as to what your goal here is.
PHP will first look in the current directory for the include file specified. If it is not there it will then look in the directory specified in the include path. So as long as you have your include file either in the current directory or in a directory that you have specified in the include path then you shouldn't have any problems.
You don't need to change that. I think that path goes to the default php folder which controls includes or something....if you just let it sit like it is, it should work fine.
Due to the way my Development, Test, and Production servers are laid out I needed to be able to reference the files by relative address versus fully qualified name or by what is in the PHP.INI file.
For instance, on my development server the included files live in /webapp/include. On test they live in /test/include. On production they live in /include. So I can't reference them as fully qualified names like "/include/header.htm" because that isn't always where they are. However, if I am in a file such as /webapp/subf1/file1.php I can reference the header file by relative address like this: include ("../../include/header.php");
When I first started this thread on Friday I swear I tried that and it didn't work. But I came back after three days of drinking over the long weekend and it worked. A good buzz never hurts I guess.
Thanks for the help.
Spookster
05-27-2003, 11:59 PM
Well yes you can do it that way. I thought you were looking for a way to set this up in php.ini. That is the part where you had me confused.
Of course, and im sure you know or at least realize this now, it is usually a good idea to set up the development and test environments to mirror the production environment.
If only I had the luxury. :) Development is on my local PC, Test is in in a subfolder on the Production web server. Hey, you've gotta do what you've gotta do.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.