|
-
August 24th, 2005, 06:22 AM
#1
how to specify the root directory of the web site?
<?php require("include/const.php"); ?>
In the quotation marks.
"/" can't be used.
I want to include the file in "http://mywebsite/include/", but I don't want to specify the website name.
-
August 24th, 2005, 01:33 PM
#2
Re: how to specify the root directory of the web site?
<?php require("../include/const.php"); ?>
should do the trick
-
August 24th, 2005, 08:36 PM
#3
Re: how to specify the root directory of the web site?

I know how to use "../",
but can I specify the root directory simply?
Because some PHP files may be moved.
If so, I'd have to modify each file.
-
August 26th, 2005, 04:30 AM
#4
Re: how to specify the root directory of the web site?
you have to specify the path on your server to the include file with phps include directive.
so if your include file lies at /usr/local/apache/htdocs/include/functions.inc
then you can do a include( '/usr/local/apache/htdocs/include/functions.inc' );
there are 10 kinds of people. those who understand binary and those who don't...
rate a post if you find it usefull, thx
check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/
-
September 6th, 2005, 07:49 PM
#5
Re: how to specify the root directory of the web site?
 Originally Posted by bigBA
you have to specify the path on your server to the include file with phps include directive.
so if your include file lies at /usr/local/apache/htdocs/include/functions.inc
then you can do a include( '/usr/local/apache/htdocs/include/functions.inc' );
using a full path like that isn't ver "portable", it won't work well on some other systems, try something like this:
include(dirname(__FILE__)."/includes/const.php");
That would make it so that wherever your file is, it will always look for the /includes/const.php file
hope it helps,
camowel
-
September 6th, 2005, 11:19 PM
#6
Re: how to specify the root directory of the web site?
well (IMHO), this should have the same effect like include('includes/const.php'), means that includes is a subdirectory of the directory where the files is in which this include statement lies.
but the op says:
Because some PHP files may be moved.
so, when he moves the file with you include, he also has to move the includes sub dir....
but you are right, this isn't very portable - but if you have to move you php files from one machine to another... which aren't equally configured, you have a lot of work to do, maybe modifying each page, too... so changing those includes wouldn't count
there are 10 kinds of people. those who understand binary and those who don't...
rate a post if you find it usefull, thx
check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/
-
September 13th, 2005, 12:34 PM
#7
Re: how to specify the root directory of the web site?
 Originally Posted by _mynameisno1
<?php require("include/const.php"); ?>
In the quotation marks.
"/" can't be used.
I want to include the file in "http://mywebsite/include/", but I don't want to specify the website name.
When faced with a similar issue, what I did was to use this:
<?php include "start.php" ?>
and then I put a little file (mine are only 1 line each) called start.php in each directory with info specific to that directory, as in WHAT directory it is. 
Once you have that, you can define (in start.php) a constant to hold the current directory and the base directory and then use that to include your files.
Were you to port the system, only the start.php files would need editing.
Hershel
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|