Do exactly what you posted, except skip the print() bit:
<?
if exists($variable){
?>
gobs of html
<?
} else { ... }
?>
And if you want to drop a variable or expression inside the gobs of html, just use <?= ?> or <? ?>.