Meta data with included header

Discussion in 'PHP' started by dtommy79, Jul 4, 2011.

  1. #1
    Hi,

    I'm creating a new website and I'm using the PHP include function with my header to reuse it on new pages.

    My problem is, if I use it like this on new pages:

    <?php include("header.php"); ?>
    PHP:
    then my title, meta description and meta keywords will be the same since those are fixed in the header.php file.

    So when i create a new page using the include function, how can I use title and meta data that is relevant to that page?

    Thanks
     
    dtommy79, Jul 4, 2011 IP
  2. vruvishal

    vruvishal Member

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #2
    Hi,
    You need to check in header.php file to which file or page is currently running. and by using that page or file name you can set meta and description tag value to relevant page...


    Vishal
     
    vruvishal, Jul 4, 2011 IP
  3. akshat.gl

    akshat.gl Member

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    You can use $_SERVER['PHP_SELF'] to identify the page and then as Vishal said, you can edit meta tags accordingly,
    sample code snippet:

    if($_SERVER['PHP_SELF'] == "/index.php")
    echo '<meta name="SIte name" description="Hey all" >';
    else if...
     
    akshat.gl, Jul 4, 2011 IP