SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    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
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    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.

  3. #3
    SitePoint Addict
    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
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  4. #4
    What's HTML?
    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

  5. #5
    SitePoint Addict
    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...

    ronnie
    Last edited by ronnie; Jun 24, 2001 at 20:50.
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  6. #6
    What's HTML?
    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

  7. #7
    SitePoint Member
    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)

  8. #8
    SitePoint Addict
    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
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  9. #9
    SitePoint Addict
    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
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •