Jump to content

how to have a different page title for each page of site using php


autofocus

Recommended Posts

Hi

i was trying to use

define($title, 'title of this page');

and then in title as follow

<title><?=$title;?></title>

 

i have separated header, content and footer and calling header and footer in each page.

 

i have different content on each page. so i wanted title relevant to content.

 

i did not get any error but script stopped after loading header.

 

i think it is easy to achieve but i have no idea at this time. please help.

thanks

 

 

You are trying to define a constant with the define function... You can find all info on every function at the php manual. http://us3.php.net/define If you want to define the term i suggest:

 

define("TITLE", 'title of this page');

<title><?php=TITLE;?></title>

 

I'm pretty sure that will work for you.

This data probably also comes from a db? Then why not store the title in it also?

 

<?php
...
$result = mysql_query($query, $db);
extract(mysql_fetch_assoc($result));
?>
<!DOCTYPE html>
<html>
<head>
    <title><?php print $title; ?></title>
</head>
<body>
    <div id="wrapper">
        <div id="content"><?php print $content; ?></div>
        ..
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.