PHP help

Schoolies

Senior member
Oct 9, 1999
495
0
76
I would like to use the php #include statement so that I can have a uniformed footer on the bottom of every page. How can I do this without making each page I put the #include statement on php?

<? include 'filename.htm'; ?>

As far as I know, if I use the above statement I need to make the web page a php file, not html, so that the code will work. But this doesn't really seem right... having all of my web pages .php instead of .htm because of the include statement?

thanks
 

Schoolies

Senior member
Oct 9, 1999
495
0
76
I also want to include one page that will have my navigation links. These navigation links will be in html, so SSI will not work, and I want these links on all pages.

I have made a couple of websites and some of them have been up to 50 pages. I have another web site coming up which I believe will have that many pages. I don't want to have all 50 pages done and then they decide they want to add one link, then i'm forced to go back and change all 50 pages. I know there is a solution to what I'm trying to do but I'm not sure if PHP is what I need.

Thanks for the advice on SSI - I have to check SSI out a little more later.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
why wont SSI work with html...I have dont it several times. Now if you really want to use PHP just for this it could look like this...

<?php include("/path/to/file"); ?> or you could use <?php require("/path/to/file"); ?> the difference being require errors out the entire page if it cant include the file. The advantage of PHP for your situation is you can move the entire site way from several pages of html to just a few PHP pages that combine different sections. It does not have to be fancy it can be just lots of functions that just spit out HTML and the combining functions to put them all togeather. The idea being you dont have tedious repeated stuff so you can just change it in one place and every thing else changes. But then again you can also use SSI to do this for the most part.
 

Schoolies

Senior member
Oct 9, 1999
495
0
76
thanks jon,

do you know where I need to put the file so that the source code can not be read? I do not want the user to be able to view my php code.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Aslong as your server is configured to server up PHP pages (if the server is working and actually executing the PHP code than it is configured)...no on will be able to see your source code. The only thing they will be able to see is the HTML you spit back to the browser. For example if you have this php page:

<?php
echo
"<HTML>
<HEAD>
<TITLE>My Page</TITLE>
</HEAD>
<BODY>
Hey look I have a php page...



look I can include files";
include("/path/to/file");
echo
"

Ok I am tired of this...time to end my page.
</BODY>
</HTML>";
?>

The only thing they would be able to see was:
<HTML>
<HEAD>
<TITLE>My Page</TITLE>
</HEAD>
<BODY>
Hey look I have a php page...



look I can include files

<!--The File you included would go here as if it was part of the page all along -->


Ok I am tired of this...time to end my page.
</BODY>
</HTML>