how to include a file from another dir

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis T. Holm

    how to include a file from another dir

    Hey

    I wonder how i can include a file from another directory....

    is this possible ?

    include('/directory/file.php');

    Dennis T. Holm


  • Michael Fesser

    #2
    Re: how to include a file from another dir

    .oO(Dennis T. Holm)
    [color=blue]
    >I wonder how i can include a file from another directory....
    >
    >is this possible ?
    >
    >include('/directory/file.php');[/color]

    If the directory exists, sure. But be aware that PHP accesses the files
    directly through the filesystem. The above would start from the root
    directory of the filesystem, not the document root of the webserver. If
    you want to start from the document root you can use something like
    this:

    include $_SERVER['DOCUMENT_ROOT'].'/file.php';

    It's also possible to access files outside the document root:

    include $_SERVER['DOCUMENT_ROOT'].'/../include/file.php';

    Micha

    Comment

    Working...