Just a little bit of help needed with the include function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris J

    Just a little bit of help needed with the include function

    Hi there,

    Say I have three files:
    test.php
    /test53/test.php
    /test692/test83/test.php

    ... and I want to include "test2.php" and "test3.php" which are in the
    main directory on each of the above pages ... I can't do <?php
    include("header .php");?>
    This is a test page!
    <?php include("footer .php"); ?>

    because the files are not in all of the directories.

    How do I include "test2.php" and "test3.php" on each page with no
    problems? I've tried

    <?php include("www.do main.com/test2.php");?>
    This is a test page!
    <?php include("www.do main.com/test3.php"); ?>

    on all pages.
    However this gives errors. Please could someone assist?

    Thanks
  • Kevin Thorpe

    #2
    Re: Just a little bit of help needed with the include function

    Chris J wrote:
    [color=blue]
    > Hi there,
    >
    > Say I have three files:
    > test.php
    > /test53/test.php
    > /test692/test83/test.php
    >
    > .. and I want to include "test2.php" and "test3.php" which are in the
    > main directory on each of the above pages ... I can't do <?php
    > include("header .php");?>
    > This is a test page!
    > <?php include("footer .php"); ?>
    >
    > because the files are not in all of the directories.
    >
    > How do I include "test2.php" and "test3.php" on each page with no
    > problems? I've tried
    >
    > <?php include("www.do main.com/test2.php");?>
    > This is a test page!
    > <?php include("www.do main.com/test3.php"); ?>
    >
    > on all pages.
    > However this gives errors. Please could someone assist?[/color]

    include works at the system level. Hence it knows nothing about the URL.

    include("$_SERV ER[DOCUMENT_ROOT]/test2.php");

    will do what you were trying to do. Alternatively put them in a separate
    directory and add that to your include path.

    Comment

    Working...