Just a word of advice, it is best to do all workings outside the html even if its just above it would be better:
PHP Code:
<?php
if(!isset($http_title))
{
$szTitle = str_replace(' ', '-', $pg_title);
}
else
{
$szTitle = str_replace(' ', '-', $http_title);
}
?>
<title><?php echo $szTitle; ?></title>
The above is much more readable, and nicer to come back to when you want to make a change 3 years down the line!