A direct url within an include

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am trying to put a direct url in this form <?php
include("messageboard.html"); ?> is it possible and what is the code?
What I am trying to do is link to a footer that opens on all pages. Any
help would be appreciated.


Re: A direct url within an include

Nancy wrote:
Quoted text here. Click to load it

It is possible and you've just given the code. Or do you experience problems  
when doing it like this?


Re: A direct url within an include

all u need is to make some HTML page and put in it any content for your
footer then in any php page in your site at the end of your code add
this code :-
and change footer.htm with the URL of your HTML page - if it is located
in the same dir with all o fyour php files so put it in this form
include("footer.php"); and if located at a remote server for example
you can use this form include("http://yahoo.com/footer.htm "); only for

if you have any more problems - reply again

Ahmed ,

Re: A direct url within an include

the footer is on the site but not in the same folder. We have tried the
short link of footer.html and also http://mydomain.com/footer.html and
neither has worked

Re: A direct url within an include

include('somefile.ext') assumes that somefile.ext is in the same
directory as the PHP file containing the include statement.  If the
included file is in another directory, for example the parent
directory, then you need to call include('../somefile.ext').  Realizing
that this can be something of a PITA when trying to include it in files
that may be spread over multiple directories, my suggestion is to
define a constant that points to the physical path to the application
root, which would allow you to do something like the following:

//in constants.php included into all page requests
define('APP_ROOT', '/opt/websites/mysite/');

//somewhere else in the application
include(APP_ROOT . 'includes/somefile.ext');

Site Timeline