SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
Thread: Different "include" path?
-
Jun 24, 2001, 15:40 #1
- Join Date
- Jul 2000
- Location
- North Central AR
- Posts
- 231
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Different "include" path?
I use a large number of includes, and was wondering if you always have to have the full path? Right now I use something like:
include "/www/user/sitename/html/file.inc.php";
Now the problem or pain comes in when I switch hosts. And the new host has a different absolute path. So I have to change literally 1,000's of pages. Like the new host's path is:
/www/user/html/sitename/file.inc.php";
I sure do not plan to switch hosts again, but if it happens I'd hate to change them all again. Any other way I can include a file? The file does pass variables. Seems like there should be another way.
Any ideas?
Thanks
ronnie
-
Jun 24, 2001, 15:57 #2
- Join Date
- Jun 2000
- Location
- Sydney, Australia
- Posts
- 3,798
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I always use relative paths. I don't know if php.ini has to be configured especially for this - relative paths have always worked fine for me.
-
Jun 24, 2001, 16:44 #3
- Join Date
- Jul 2000
- Location
- North Central AR
- Posts
- 231
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Freaky
But the include files will have to be in the same directory right? I draw one file accross many directories, so would not help me much. Thats my whole reason for using include, change one file, change them all..
ronnie
-
Jun 24, 2001, 18:58 #4
- Join Date
- May 2001
- Location
- San Diego, CA
- Posts
- 1,701
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The included file doesn't need to be in the same directory. You can access files above and below your directory. For example, "articles/include.php" and "../include.php" should both work. The ".." take you back a directory.
I always use absolute paths so I can upload my file to any directory and know that it will work without editing the location.Ryan Kuhle - A Proud Advisor - Got Questions? Just Ask!
Get your website started for less than $20! Click Here
-
Jun 24, 2001, 20:46 #5
- Join Date
- Jul 2000
- Location
- North Central AR
- Posts
- 231
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks RKuhle,
Unfortunately, that won't work for me as I include files across several domains. Seems like there's no easy answer for me.
I agree the absolute paths are the best.
This whole thing is not a big deal unless I switch hosts, which I do not like to do, but sometimes I have to. And if there's a different path, I have to change 1,000's of pages. Just trying to save my self a ton of changes in the future if I have to switch.
From what I read you can't us a URL for include right? Like
http://www.mysite.com/includes/file.inc.php
right? That would work great for me...
ronnieLast edited by ronnie; Jun 24, 2001 at 20:50.
-
Jun 24, 2001, 21:11 #6
- Join Date
- May 2001
- Location
- San Diego, CA
- Posts
- 1,701
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've got great news for you, you CAN use the URL as the parameter as long as "URL fopen wrappers" are enabled in the PHP configuration, which they are by default.
Ryan Kuhle - A Proud Advisor - Got Questions? Just Ask!
Get your website started for less than $20! Click Here
-
Jun 24, 2001, 23:50 #7
- Join Date
- Jun 2001
- Location
- CA
- Posts
- 9
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Why not just go put a config in the base dir of each site with:
$fuggly_stuff = "/www/path/to/sitename";
$relative = "/www/includes/";
then go
require("./config.inc.php");
include($fuggly_stuff . $relative . "file.php");
on each page. If you're doing anything with databases you should already have a config or connection type file, just throw it on in there.Ripped_Edge
ripped_edge@hotmail.com
http://www.452productions.com
World Domination on a Global Scale (TM)
-
Jun 25, 2001, 09:21 #8
- Join Date
- Jul 2000
- Location
- North Central AR
- Posts
- 231
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thats a great idea ripped.
I could also use include instead of require right? What I don't like about require is, if the required file is not found the entire page will not work, if I understand it right. Or am I thinking wrong?
But even still doing it this way I would only have to change one file per domain instead of 1,000's per domain. This would save ALOT of time..
Thanks for the idea!
ronnie
-
Jun 26, 2001, 08:42 #9
- Join Date
- Jul 2000
- Location
- North Central AR
- Posts
- 231
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Since I am sure not a php expert, is there a reason why a host would'nt want to enable "URL fopen wrappers"? Or on php 4.04 I think it is now called "allow_url_fopen, right?
Does it cause more sever load or is it a security issue?
Thanks.
ronnie
Bookmarks