Escaping String

Maybe I’m missing something, but I’m trying to use escape() on a string and I’m getting an error, “Call to a member function escape() on string”.

<h2>Showing results for &ldquo;<?= $query->escape() ?>&rdquo;</h2>

You can use esc() helper function:

<?= esc($query) ?>

The way you are trying to use it above only works for fields (because escape() is a field method).