Tags and Includes – A Lesson on Proper HTML Structure Embedding within PHP

Often in PHP you find simple sites structured as follows

index.php
<?php
$title = 'page title';
$description = 'desc';
$keywords = 'keywords';
include('includes/header.inc.php');
?>
Our Page Content
<?php include('includes/footer.inc.php'); ?>
includes/header.inc.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?= $title ?></title>
<meta name="description" content="<?= $description ?>" />
<meta name="keywords" content="<?php if(empty($keywords)){
echo 'Default Keywords';
}else{
echo $keywords;
} ?>" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/print.css" rel="stylesheet" type="text/css" media="print" />

 

</head>
<body> <div id="page_wrap"> <div id="header" > <a href="index.php"><img src="images/logo.jpg" border="0" /></a>
</div>

Whereas