[TUT] How to make, and call headers and footers. - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: [TUT] How to make, and call headers and footers. (/showthread.php?tid=7001) |
[TUT] How to make, and call headers and footers. - Extasey - 05-12-2010 Every good website has one, and frankly, I thinks its weird without one! A header is usually the top "bar" or panel on a page, and a footer is most commonly a copy write notice. I'm assuming you have the basic PHP syntax down. So, first, we are going to create a file called "header.php", notice I don't use capitals, as if you accidently forget the capital, links and crap won't work. Just easier to use a single case. In this file, your going to construct your header, heres a bit of code to start you off: PHP Code: <html> This should be pretty straight forward, especially if you copy paste it into a program that will allow previews (e.g. Dreamweaver). You obviously have to change your page title. Try changing your Heading to a picture and making the choices links. Now, were going to make a file called "footer.php" This is just a simple copywrite notice thats down the bottom of the page, you can also include links such as contact us, feedback etc etc. Heres some easy code: PHP Code: <hr> Easy!! Now, the trickiest part of all! I assume your looking at this page because you are already in the process of constructing a site and are wondering how the hell you do it! Go to your index, or whatever page you wish to call the header and footer on, and put the following code PHP Code: <?php include 'header.php'; ?> As you can see, the code "<?php include 'header.php'; ?>" is what calls it. You can pretty much just copy and paste that line and put it where you want the header to go. Same for the footer! How easy is that?! NOTE: This will only work if the header and footer are located within the root directory. If you wish for teh website to call it from the same directory your page is in, type "<?php include '../header.php'; ?> HERE is an example of this in use. This is a site I put together in about half an hour, making all the graphics in the same sitting. It was intended for school, but I got in trouble for planning to host a game, game downloads, and a proxy on the school server, thats why the site wasn't completed. Here is the source for my header: PHP Code: <body> This process can quiet easily be applied to other objects, such as sidebars. Enjoy! I seperated some of the code onto seperate lines to keep this page within normal boundaries! You will have to fix this If you want to use mine, but no hints because thats not learning! |