Jump to content

using somthing along the lines of str_replace for unique page titles


koolaidman52

Recommended Posts

on my site i include header.php, this page includes everything down to the unique content area for each page ("<div class="body">" is the last thing on the page.) unfortunately that means that the header is the same for every page and the title is the same as well.

so my question is, can i use str_replace() in each page that I include the header page in and change the title for each page as well? If yes, then how?

I hope that's clear enought to comprehend.
how about this instead:


contact.php
[code=php:0]
<?php
$title = 'My contact page';
include header.php;
echo '<p>Contact me</p>';
include footer.php;
?>
[/code]


header.php:
[code=php:0]
<?php
echo "
<!-- Doctype and other necessary tags come here -->
<title>$title</title>
</html>
<body>
";
?>
[/code]




this is just an example. the system can be optimized but that should fix the str_replace() problem for you

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.