1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do I create a dynamic title?

Discussion in 'PHP' started by wwwbryan, Mar 28, 2009.

  1. #1
    I have an index.php file which tells the direction of the pages.

    So like if its index.php?page=monkey

    Then it will show the monkey.php page, which would contain

    Hello this is the monkey page. Picofmonkey.gif, etc.
    Code (markup):

    and nothing else.

    How would I make the index.php know what to put for the page title.

    Like have the monkey page like

    
    define('PAGETITLE', 'The monkey page!');
    Hello this is the monkey page. Picofmonkey.gif, etc.
    
    Code (markup):
    But the title tag will obviously be before where it defines it, so I don't know the best way to get this accomplished.
     
    wwwbryan, Mar 28, 2009 IP
  2. AkkuDreamz

    AkkuDreamz Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    keep the titles list in the php code above your content or before including your content
    make a choice out of the titles (using switch or if-else) to check the 'page' 's value
    and then in when the html content begins do something like

    
    <head>
    <title>
    <?php
    echo constant("PAGETITLE");
    ?>
    </title>
    </head>
    
    Code (markup):
    make sure the pagetitle is defined on the basis of conditions only
     
    AkkuDreamz, Mar 28, 2009 IP
  3. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #3
    <?php define("TITLE", "Monkeys page"); ?>
    <html>
    <head>
    <title> <?php print(TITLE); ?> </title>
    </head>
    <body>
    Your content goes here ..
    </body>
    </html>
    PHP:
     
    ActiveFrost, Mar 28, 2009 IP
  4. wwwbryan

    wwwbryan Well-Known Member

    Messages:
    181
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #4
    I found out a better way by using templates.
     
    wwwbryan, Mar 29, 2009 IP