page.php:
header.php:
&
Expanding a little on we.mamat's answer, you could use a preg_replace instead of the simple replace and remove the need for a %title% altogether. Something like this:
)(.*?)(<\/title>)/i', '$1' . $title . '$3', $buffer); echo $buffer; ?>