Simple PHP Design?

Discussion in 'HTML & Website Design' started by sixty6, Jan 18, 2008.

  1. #1
    I want to integrate PHP into my design for a website so I don't have to manually go and change EVERY single page if I changed something in the header or the footer.

    Is anyone able to give me a simple rundown on how I can make the header call a certain file and the footer call a different file? I'd appreciate it!
     
    sixty6, Jan 18, 2008 IP
  2. awatson

    awatson Active Member

    Messages:
    112
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Well, you'll basically want to create a "header.php" and "footer.php" file, then include them in your code where you want the contents of those files to show up using the php include code "<?php include("/path/to/includes/header.php") ?>" - pretty straightforward.
     
    awatson, Jan 18, 2008 IP
    sixty6 likes this.
  3. sixty6

    sixty6 Well-Known Member

    Messages:
    1,748
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    190
    #3
    Thanks! I know that XHTML files usually have a declaring statement at the top, do I need to do anything like that with a PHP file?

    Also would I be able to save it as a .html file?
     
    sixty6, Jan 18, 2008 IP
  4. awatson

    awatson Active Member

    Messages:
    112
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    No, it'll have to be saved as a .php file, unless you set up your server differently.
     
    awatson, Jan 18, 2008 IP
  5. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #5
    The <?php says the following is php code.
    and
    the ?> says this is the end of the php code.

    Note that the "" were added in the post above they are not used on your page and a ; was omitted. The actual line reads
    <?php include("/path/to/includes/header.php"); ?>

    If you already have pages that are indexed you should either make html server parsed to keep the extension or set up redirects to the new pages.
     
    Colbyt, Jan 18, 2008 IP
    sixty6 likes this.
  6. sixty6

    sixty6 Well-Known Member

    Messages:
    1,748
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    190
    #6
    ah ok, thanks for the correction colby! I plan on having something up over the weekend, thanks for the help!
     
    sixty6, Jan 18, 2008 IP