Paths & Source Strings

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Paths & Source Strings

Post 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?
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post 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?
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

yes

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that's the document root, not your file system root.
Post Reply