Forum Moderators: mack

Message Too Old, No Replies

Should I use PHP, Javascript or ___ for this?

         

gemini18

9:52 pm on Dec 28, 2005 (gmt 0)

10+ Year Member



(I didn't mean to start duplicate threads. This question is about the best overall way, and a thread in the PHP section asks how (with PHP)?

I need the name of individual web pages %title% (?) to appear at the top of a section. When the simple two or three word page title gets changed the top section title will automatically match.

Exactly, how do I do this, please, and what is the precise variable name for the title of a Dreamweaver made page?

Thank you.

mack

1:37 pm on Jan 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If your pages are wreitten in php then the following should work to display the page title within a webpage...

echo $PHP_SELF

Mack.

seopod

12:48 am on Jan 5, 2006 (gmt 0)



Are you meaning the page name ex. widget.php or an actual page title ex. "The World of Widgets"?

If the page name is what you are after then Mack is right, however, if you are after the actual title then you will have to go a different route.

In this case both PHP and JavaScript will both be efficient at this task.

PHP


<?php
$title="The World of Widgets";
echo $title;
?>

JavaScript

Use this in the <head>


<script language="JavaScript">
function title() {
var title = "The World of Widgets"
document.write(title)
}
</script>

Use this where you want the title to show up


<script language="JavaScript">
title()
</script>