HTML is a "Hyper Text" display language and can be only used to display text in a formated manner via a web browser. PHP is the most widely used scripting language and can be used on the command line to produce local results or serve the results to a web browser request via the internet/intranet . i.e. format and display a page viewable with a web browser. However, if you want to serve the html up to web clients you will need to do so via a web server.
You can use the code you supplied but you have to display it with a web browser. The web browser will read the tags and display the contents without displaying the tags.
Simply put - scripts are used to perform tasks and commands and the html tags are used to display results in a formatted fashion with a web broweser.
<html>
<title>HTML with PHP</title>
<body>
<h1>My Example</h1>
<?php
//your php code here
?>
<b>Here is some more HTML</b>
<?php
//more php code
?>
</body>
</html>
You can remove the php script and generate a html page by using echo or print on each line with a bash or ksh script and then open the doc with a web browser to view the document.
FYI - The php script won't work unless it's on a webserver.