Advanced HTML
Tables
Frames
Passwords
HTML Colours
Animated Buttons
Buying Webspace
Search Engines
Making Money
.htaccess Files
PHP Tips
JavaScript
Java Menu
favicon.ico
HTML Converter
HTML Books
Basic Tags
FAQ
Contact Us

PHP Tips

Including common files in your page

A very useful technique for making it easier to create web sites is to have common elements such as menus, headers and footers in separate files which are then included into your main web pages. This has a number of advantages.
  1. Your site becomes easier to build as you can make much of each page up using standard building blocks rather than starting each page from scratch.
  2. You can easily update the common parts of your site by making a change to a single file rather than having to update every single page.
The syntax to include another file is very straight forward. e.g. the below snippet will include a file directly into the current page. This is what I use to include the standard menu that you see on the left of each page on www.advancedhtml.co.uk.
<?php
include_once('menu-links.inc');
?>
Below is a simplified version of what my menu-links.inc contains. Each time I update the menu all the pages on this site are automatically updated.
<A HREF="/index.html">
  <IMG SRC="/advancedhtml.gif">
</A>

<P>
 <FONT SIZE="-1" FACE=ARIAL>
  <A HREF="/advancedhtml.htm"">Advanced HTML</A><BR>
  <A HREF="/tables.htm"">Tables</A><BR>
  <A HREF="/frame.htm"">Frames</A><BR>
  <A HREF="/password.htm"">Passwords</A><BR>
  <A HREF="/colours.htm"">HTML Colours</A><BR>
  <A HREF="/webspace.htm"">Buying Webspace</A><BR>
 </FONT>
</P>
For this to work you just need menu-links.inc to be in the same directory as your .html or .php files.

Keeping your copyright footer up to date automatically

Imagine that in 2007 you create a webpage and you add a copyright footer. Time passes and we reach 2008. The problem is that your copyright footer is now out of date. There is an easy way to sort this out. Use some simple PHP to keep the current year up to date.
<CENTER>
<FONT SIZE="-2" FACE="Arial">

<?php
$today = getdate();
print "Copyright &copy; 1997 - ".$today["year"];
?>

</FONT>
</CENTER>
If the current year is 2007 then the output will be 'Copyright © 1997 - 2007'.


  The  
Advanced  HTML
Site
Home
Copyright © 1997 - 2008
Hosted by 1&1