In addition to using functions such as echo and print, you can also end your script, and anything beyond the end of the script will be output as normal HTML to the browser. You can also restart your script whenever you want after you've closed the PHP tag. Confused? It's actually pretty simple.
Let's say you had a for loop to count up to five and output it.
<?php
echo("<ul>");
for($x = 1; $x < 6; $x++)
{
echo("<li>" . $x . "</li>");
}
echo("</ul>");
?>
While I would tend to use templates for larger pages that output a lot, we'll get to that later. Remember how all your PHP scripts start with <?php and end with ?>? Those don't have to be the very start and end of your file. In fact, PHP handles ending and restarting scripting just like if everything between the ?> and <?php tags were inside of an echo statement.
Thus, you could do something like this:
<ul>
<?php
for($x = 1; $x < 6; $x++)
{
?>
<li><?php echo $x ?></li>
<?php
}
?>
</ul>
This is actually a very common method of outputting variables in a script, especially if there is a lot of HTML surrounding the variables. As I said before, I personally rarely ever do this, as in my opinion, using echo for smaller scripts keeps your code cleaner (and I would use templates for larger ones). However, we want to cover most of the language here, so this is another method you could use.