Page 1 of 1

Paths & Source Strings

Posted: Fri Jan 21, 2005 7:05 am
by AliasBDI
I'm on a Windows server running the latest PHP version. When trying to 'require' or 'include' it is not allowing me to use the "/" to begin my paths to the source page. These includes will be on multiple pages throughout the directory levels so it is very important that this work. Should it not be working on my server (or in PHP at all)? Here is an example:

Code: Select all

// the file name "file.php" is in a folder named "includes" on the root
<?php include('/includes/file.php'); ?> // will not work

<?php include('../../includes/file.php'); ?> // works fine
Any ideas?

Posted: Fri Jan 21, 2005 8:11 am
by redmonkey
A leading / refers to the root of the filesystem and does work on win32 platforms with no problems.

For example, if you are working on your C drive and you request a file with the path '/includes/file.php' it will be looking for the file 'C:\includes\file.php' I'm guessing that your includes directory is not in the root of the file system?

yes

Posted: Sat Jan 22, 2005 11:24 am
by AliasBDI
Actually it is. When you go to http://www.domainname.com that is the root. So the folder is in http://www.domainname.com/includes/file.php. And it is not working. Is this not the root?

Posted: Sat Jan 22, 2005 12:30 pm
by feyd
that's the document root, not your file system root.