Using the <h2> as the title after sent?
- by Delan Azabani
Currently, I have a semi-dynamic system for my website's pages. head.php has all the tags before the content body, foot.php the tags after. Any page using the main theme will include head.php, then write the content, then output foot.php. Currently, to be able to set the title, I quickly set a variable $title before inclusion:
<?php $title = 'Untitled document'; include_once '../head.php'; ?>
<h2>Untitled document</h2>
Content here...
<?php include_once '../foot.php'; ?>
So that in head.php...
<title><?php echo $title; ?> | Delan Azabani</title>
However, this seems kludgy as the title is most of the time, the same as the content of the h2 tag. Is there a way I can get PHP to read the content of h2, track back and insert it, then send the whole thing at the end?