Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    echo <TITLE>this</TITLE>

    Is it possible to echo the title of a page?

    Code:
    <htad>
    <title>Page 1</title>
    </head>
    
    ........................
    
    You are here: <?php echo TITLE ?>
    <div> - putting your mind in a box since 1997

  • #2
    New Coder
    Join Date
    Aug 2007
    Posts
    53
    Thanks
    11
    Thanked 2 Times in 2 Posts
    I would just use a variable for the title name that way
    you can use it wherever you want.
    PHP Code:
    <?php $title="idk" ?>
    <html>
    <head>
    <title><?php=$title ?></title>
    </head>

  • Users who have thanked JustBlaze for this post:

    ArcticFox (11-17-2007)

  • #3
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts
    I thought about that, but this code is for a site that's already coded with dynamic titles - I'm not sure if I want to dig into it all to find the part I'm looking for.
    <div> - putting your mind in a box since 1997

  • #4
    Regular Coder
    Join Date
    Nov 2006
    Posts
    246
    Thanks
    13
    Thanked 26 Times in 24 Posts
    Yeah, there's no way to do that.

    <?php $title = "page 1"; ?>
    <html>
    <head>
    <title><?php echo $title; ?></title>
    </head>

    ........................

    You are here: <?php echo $title; ?>

  • Users who have thanked Majoracle for this post:

    ArcticFox (11-17-2007)

  • #5
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts
    That's what I thought.

    Thanks guys.
    <div> - putting your mind in a box since 1997

  • #6
    New Coder
    Join Date
    Aug 2007
    Posts
    53
    Thanks
    11
    Thanked 2 Times in 2 Posts
    ah, always fun digging through someone else's work.

    Best of luck on this
    -JustBlaze

  • #7
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Actually, you can do this a couple of ways:
    Javascript (This may not work with all browsers, but it works with IE7 & FF):
    Code:
    You are here: 
    <script type="text/javascript">
    	document.write(document.title);
    </script>
    PHP:
    PHP Code:
    <html>
    <head>
    <title><?php ob_start();?>this is the title<?php $title ob_get_clean();?></title>
    </head>
    <body>
    <?php echo $title;?>
    </body>
    </html>
    You can put the output buffering around whatever code outputs the title.
    If your site already uses output buffering you can use ob_get_contents(); to get the output thus far, and parse the title out of it. There are probably a couple of other ways you could do it too..


  •  

    Posting Permissions

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