This is a discussion on Just a little bit of help needed with the include function within the PHP Language forums, part of the PHP Programming Forums category; Hi there, Say I have three files: test.php /test53/test.php /test692/test83/test.php ... and I want to ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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.domain.com/test2.php");?> This is a test page! <?php include("www.domain.com/test3.php"); ?> on all pages. However this gives errors. Please could someone assist? Thanks |
|
|||
|
Chris J wrote:
> 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.domain.com/test2.php");?> > This is a test page! > <?php include("www.domain.com/test3.php"); ?> > > on all pages. > However this gives errors. Please could someone assist? include works at the system level. Hence it knows nothing about the URL. include("$_SERVER[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. |