Well, a better way might be something like this.
<?php
// store the result of the function "compose_message()"
// in the variables $title and $msg
list ($title,$msg) = compose_message();
?><html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1><?php echo $title; ?></h1>
<?php echo $msg; ?>
</body>
</html>
<?php
// The function can be located anywhere
// in the document. In this example, the function
// returns two values in an array: title and message
function compose_msg() {
$ttl = 'This is my title';
$message= '<p>Thank you for your interest.</p>';
return array ($ttl,$message);
}
?>
(This code **should** run if you want to drop it in a PHP file and test it.) See how it drops "in and out" of PHP? I use a function there to group the programming in one place, too often PHP documents are a long series of in and out PHP, it becomes very hard to follow and maintain (called "spaghetti code.") By putting your message composition in a function, it minimizes this and allows you to move it around where you want - like, in an include, for example
<?php
// here the call to compose_message and
// the function itself are stored in an
// external file
include('compose-message.php');
?><html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1><?php echo $title; ?></h1>
<?php echo $msg; ?>
</body>
</html>
Look how neat and easy that is to understand. :-) A templating system is by far a better choice, but for a simple one-off document, this approach will teach you a couple things and build your knowledge of PHP - you can expand later into templates after your feet are wet.