...

View Full Version : echo <TITLE>this</TITLE>



ArcticFox
11-17-2007, 08:38 PM
Is it possible to echo the title of a page?



<htad>
<title>Page 1</title>
</head>

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

You are here: <?php echo TITLE ?>

JustBlaze
11-17-2007, 08:40 PM
I would just use a variable for the title name that way
you can use it wherever you want.


<?php $title="idk" ?>
<html>
<head>
<title><?php=$title ?></title>
</head>

ArcticFox
11-17-2007, 08:46 PM
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.

Majoracle
11-17-2007, 08:47 PM
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; ?>

ArcticFox
11-17-2007, 08:48 PM
That's what I thought.

Thanks guys.

JustBlaze
11-17-2007, 08:48 PM
ah, always fun digging through someone else's work.

Best of luck on this
-JustBlaze

Inigoesdr
11-17-2007, 09:47 PM
Actually, you can do this a couple of ways:
Javascript (This may not work with all browsers, but it works with IE7 & FF):

You are here:
<script type="text/javascript">
document.write(document.title);
</script>
PHP:


<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(); (http://php.net/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..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum