Re: getting absolute directory path?
- From: "C. (http://symcbean.blogspot.com/)" <colin.mckinnon@xxxxxxxxx>
- Date: Fri, 25 Apr 2008 05:18:01 -0700 (PDT)
On 24 Apr, 16:32, lawp...@xxxxxxxxx wrote:
First of all, I have a website under /home/user/www/. The index.php
and all the other website pages are under /home/user/www/. For
functions that are used in multiple files, I have php files under /
home/user/www/functions/. These files simply have
So, in index.php and other files, I have
<?php
include("./functions/function.create_html_page.inc");
include("./functions/function.create_pdf.inc");
....
?>
And then function files, such as function.create_html_page.inc
<?php
function create_html_page( $arg1, $arg2 ) {
...}
?>
So, my php pages have relative references to the function files, i.e.
"./functions/".
This works okay, but when I want to include a function in a function
file, I have to change the relative path. So, instead of
include("./functions/function.create_pdf.inc");
I should have
include("./function.create_pdf.inc");
Ideally I would like to figure out the absolute path name, so that I
don't have to change the relative path names depending on whether the
file is in the root directory or the functions directory, or any other
directory for that matter.
No.
Put all your include files in a directory referenced by the ini
include_path (or a specific sub-directory thereof). Then its a no
brainer to always reference the right file regardless of where it is
included from.
My website is designed so that pages in subdirectories are never
served; the user is always navigating in the root directory. So, even
if a function in the functions subdirectory are called, the original
executing script was in the root.
Setting yourself such a constraint is a very bad idea - its
ridiculously restrictive and encourages bad habits (dumping too many
files into one folder).
C.
.
- Follow-Ups:
- Re: getting absolute directory path?
- From: lawpoop
- Re: getting absolute directory path?
- References:
- getting absolute directory path?
- From: lawpoop
- getting absolute directory path?
- Prev by Date: Re: Multipage form keeps getting back to home page
- Next by Date: Re: Sessions not working in windows vista
- Previous by thread: Re: getting absolute directory path?
- Next by thread: Re: getting absolute directory path?
- Index(es):
Relevant Pages
|