There's a million ways.
You could have your page like:
<?php
require('themetop.php');
?>
.
.
<!-- usual html or php stuff here -->
.
.
.
<?php
require('themefoot.php');
?>
and then put background colors, title/head tags, various other settings, and your body tag in themetop.php and your copyright notices, etc. in themefoot.php.
Then all these pages you are producing with the 2 requires are "portable" and can be moved from one folder to another and if each folder has different versions of themetop.php and themefoot.php, then the page will change in appearance.
As for search/replace/regex, there's a million ways.
You could use heredoc notation.
<?php
// define all your variables up here.
$data=<<<QQQ
<html>
<head><title>{$pagetitle}</title></head>
<body background=FFFFFF text=000000>
<center><h1>Welcome to {$pagename}'s Web</h1></center>
.
.
.
</body>
</html>
QQQ;
echo QQQ;
?>
Note that heredoc does not allow any kind of evaluation within the structure. You must prepare all your data BEFORE the heredoc construct so that these values are ready to be inserted with the {} notation.
And then there are, of course, the aforementioned str_replace and regex version.