<?php $mensaje = ''; // ... if (/* ... */) { $mensaje = 'algo ocurrio'; } ?><html> ... <?php if ( ! empty($mensaje)) { echo $mensaje; } ?>