PHP Variable page title.

Discussion in 'Web Design and Development' started by Dal123, Jan 3, 2014.

  1. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #1
    I'm having problems echoing out my <title> tag.

    On the same page I have my html 5 as:
    Code:
    <title><?php echo $pagetitle;?></title>
    In the header section.

    A little below in the same document I then have:
    PHP:
    <?php $pagetitle='My cool title';?>
    However it is not working. I thought this was a global scope and when the directories were of a different structure in my old website this used to work.

    Does anyone know why this won't work and how I can get it to work?
     
  2. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #2
    You have to define the $pagetitle variable BEFORE you can echo it.
     
  3. slayerizer macrumors 6502a

    slayerizer

    Joined:
    Nov 9, 2012
    Location:
    Canada
    #3
    you need to set your $pagetitle before the echo occurs. You seems to be setting the value after.
     

Share This Page