PHP/MySQL Custom message for empty result set

I’m writing a PHP tutorial. Of course, when I echo HTML tags they get interpreted by the browser, so I do this:

$output .= str_replace('<', '&lt', $output);
$output .= str_replace('>', '&gt', $output);

But then, at $output I have this <div class=“example”>, so I DO NOT WANT html to get interpreted only if is surrounded by the div class=“example”. All other HTML tags outsite the div class=“example” should be interpreted.

Suggestions?

sorry, TITLE mistake, how can I remove this entry?