Results 1 to 3 of 3

Thread: Advanced PHP Include Question

  1. #1
    Join Date
    Jan 2007
    Location
    Boulder City, Nevada
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Advanced PHP Include Question

    I have a virtual server (same ip address) with many domains on it.
    I also have a few standard php files; Functions, Header, Footer, ect. that I use on many of these sites!

    The question is; Is there some way to include the common files from a central location, instead of have to duplicate them for each domain.

    It really would speed things up if I did not have to upgrade the same file under each domain, when changes are made to any of the common files!

    Thanks...
    Any ideas appreciated!

  2. #2
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    if they are all on the same server, you can include them by the path. for example just doing C:\Program Files\apache\htdocs\header.php instead of header.php

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    They don't even need to be on the same server. Include works with remote files too (if enabled; some security setups dissalow this).

    However, only local scripts will work with the script (parse the code of the included file as if it were in the PHP file itself, continuing variable names and such.). If you are OK with just the standard output of the included file, then you can have it on a remote server just fine.

    If you do need it to relate to the script, then I would suggest using GET variables, like this:
    include('http://myother.com/page.php?var1=4');

    And in the page.php,
    $var1 = $_GET['var1']; //now==4


    I hope this helps.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •