By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,729 Members | 1,433 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,729 IT Pros & Developers. It's quick & easy.

Just a little bit of help needed with the include function

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.