|
Using headers and footers in PHP
|
|
05-22-2010, 04:16 AM
Post: #1
|
|||
|
|||
|
Using headers and footers in PHP
One of the common tasks when you make a site in PHP is calling headers and footers.
A header is usually the top "bar" or panel on a page, and a footer is most commonly a copy write notice. You need to create a file called "header.php", notice I don't use capitals, as if you accidentally 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, here is a bit of code for start : 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 that's down the bottom of the page, you can also include links such as contact us, feedback etc etc. Code should look like : PHP Code: <hr>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> There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
05-22-2010, 04:47 AM
Post: #2
|
|||
|
|||
|
RE: Using headers and footers in PHP
Yup. I use this on all of my websites. Simplifies maintenance greatly. It also allows my to include any needed php files within the header so that functions don't have to be re-created or files included within every file.
Free image hosting at http://myph.us. |
|||
|
08-25-2010, 11:36 PM
Post: #3
|
|||
|
|||
|
RE: Using headers and footers in PHP
Your HTML would make every strict browser, and every person that's even remotely familiar with the W3C standards throw up their guts.
|
|||
|
08-25-2010, 11:52 PM
Post: #4
|
|||
|
|||
|
RE: Using headers and footers in PHP
Kirth,
I think the point of the post was to show how to use php header/footer includes rather than to demonstrate proper html techniques. Also, please try to remember that criticism should be constructive, rather than just complaining about something. Free image hosting at http://myph.us. |
|||
|
08-26-2010, 12:27 AM
Post: #5
|
|||
|
|||
RE: Using headers and footers in PHP
(08-25-2010 11:36 PM)Kirth Wrote: Your HTML would make every strict browser, and every person that's even remotely familiar with the W3C standards throw up their guts.Well this is just a tutorial "for dummies". It's not something spectacular. I understand what you want to say, but this is PHP after all. There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
08-26-2010, 12:36 AM
Post: #6
|
|||
|
|||
RE: Using headers and footers in PHP
(08-26-2010 12:27 AM)drdebcol Wrote:(08-25-2010 11:36 PM)Kirth Wrote: Your HTML would make every strict browser, and every person that's even remotely familiar with the W3C standards throw up their guts.Well this is just a tutorial "for dummies". It's not something spectacular. That, sir, is a very poor excuse. What you're saying would conform with the idea that when I'd give driving lessons, it'd be perfectly fine to kill someone whilst yelling "OLOL PEDESTRIAN", when I'm teaching about stop signs. |
|||
|
« Next Oldest | Next Newest »
|





