php: Dynamic Titles...

Discussion in 'Web Design & Coding' started by penguin, Aug 4, 2005.

  1. penguin

    penguin g0t r00t?

    Messages:
    101
    How would I go about doing dynamic title with php? I would like it so that the page title would be the name of the page being called.

    for example.

    http://www.mysite.com/?p=about Would be titled About.
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    PHP:
    <title>Site Name <? if (isset($_GET[p])) { print " - $_GET[p]"; } ?></title>
    You can use ucwords(); to make things a bit neater too.
     
  3. penguin

    penguin g0t r00t?

    Messages:
    101
    Thanks S_B.

    How exactly would I use the ucwords(); ? (I know enough php to be dangerous:p)
     
  4. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    Like so:
    PHP:
    <title>Site Name <? if (isset($_GET[p])) { print " - "ucwords($_GET[p]); } ?></title>
    :)