Very usefull when optimizing your website for search engines, this tutorial will show you how to keep in one single page which you will include in all others, the dynamic titles script for different pages. This will help keep your website on the headlines recommended by every seo guys. We will need to make a variable to get the page, and put an switch & case feature to estabilish the title, then we’ll print the resulted title.
<?php $page = $_SERVER['PHP_SELF']; if(isset($page)) { switch($page) { case "index.php": $title = "this is homepage"; break; case "products": $title = "products"; break; case "contact": $title = "contact"; break; } }else{ $title = "default title"; } print "<title>$title</title>"; ?>
Enjoy!