SitePoint Sponsor

User Tag List

Results 1 to 15 of 15

Thread: PHP get_header

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP get_header

    Hi,

    I have created some page and i have a footer and header .php files with the header and footer xhtml code inside it. Here comes the bit i can't do, i have a index page and i like to include those files in the index, somehow call them.

    I used the code
    Code:
    <?php get_header(); ?>
    but it didn't work, anyone has any idea how i can do this?

    Thanks,
    Yizi
    The quieter you become the more you are able to hear

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    include($_SERVER['DOCUMENT_ROOT']."/path_to/header.php"); 

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tripy View Post
    PHP Code:
    include($_SERVER['DOCUMENT_ROOT']."/path_to/header.php"); 
    Does that go in the same page?
    The quieter you become the more you are able to hear

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should go in the pages where you want your header to be included.
    The include() function inserts the content of the included file into the current document, at the place this function is called
    http://www.php.net/include/

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK i got how it works now, thanks so much!
    The quieter you become the more you are able to hear

  6. #6
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK it's not working, i want to have a single header, i have few pages that use the same header and footer, the template is coded in xHTML and CSS anyone can give me a step instructions how to create and get it working? Thanks!
    The quieter you become the more you are able to hear

  7. #7
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You need to be a bit more specific than 'not working'. What is happening? Is there an error message?

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The header wont show like it should makes the page plain and without an style!
    The quieter you become the more you are able to hear

  9. #9
    SitePoint Zealot
    Join Date
    Aug 2007
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean that all of the content is being displayed but none of the CSS styling has been applied? If that's the case, check that the path to your CSS file(s) is correct.

  10. #10
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No not just the CSS its the header that isn't displayed CSS is inside it.
    The quieter you become the more you are able to hear

  11. #11
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK i manage to get the include working, just tested it with a echo in the header.php but when i acually add the php tags (<?php ?>) and include the html tags for the header section inside it i get error.

    Parse error: syntax error, unexpected '<' in C:\server\www\ivyhomes\header.php on line 2

    I header php line to i have this code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    The quieter you become the more you are able to hear

  12. #12
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Yizi View Post
    I header php line to i have this code:
    What?

    Can you post the first few lines of your file?
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.

  13. #13
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the header.php i have this file! Sorry i was typing fast and didn't know what i was typing.
    The quieter you become the more you are able to hear

  14. #14
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone? i still didn't manage to solve the problem.
    The quieter you become the more you are able to hear

  15. #15
    SitePoint Zealot
    Join Date
    Jan 2008
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK OK OK here is the solution, don't add PHP tags inside the header.php and it will work!
    The quieter you become the more you are able to hear


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •