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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.