Nothing wrong with that approach. I like to functionalize it, so that I have to supply it with the title (and perhaps description, keywords, etc can be either required or optional parameters)
include.php:
function htmlHead($title, $description=null, $keywords=null)
{
$html = "<!DOCTYPE html>\n<html>\n<head>\n<title>".htmlspecialchars($title)."</title>\n";
$html .= "<meta charset='UTF-8' />\n";
if(!empty($description)) {
$html .= "<meta name='description' content='".htmlspecialchars($description)." />\n";
}
if(!empty($keywords)) {
$html .= "<meta name='keywords' content='".htmlspecialchars($keywords)." />\n";
}
$html .= "</head>\n<body>\n";
return $html;
}
Usage:
<?php
include 'include.php';
echo htmlHead("Test Page", "This is only a test.");