You can put anything you want into a function. You can even skip out of php into html if you've got large chucks of html and you want to avoid masses of echo commands
notionlogic's example is only lacking the call method!
But lets say you wanted a nice table with 1 row, 1 columd with a border and you wanted to use that table but with different text contents at different points in your script:
<?PHP
function tabletise($string) {
?>
<table border=1 width=100% cellspacing=2 cellpadding=3 bgcolor=#000000>
<tr>
<td valign=top bgcolor=#FFFFFF><?PHP echo $string; ?></tr>
</tr>
</table>
<?PHP
}
?>
Now in your script at the point where you want that function invoked you simply call it with
tabletise($mytextstring);