Consider this code for instance:

<?php echo MyLib::getSection($row);?>

where MyLib:

abstract class MyLib
    public static function getSection($row)
        return '<span title="$row->tooltip">'.$row->text.'</span>';

But I need to escape the values in $row->tooltip and $row->text. Is there an equivalent of $this->escape() that I can call from within the getSection() method? If I were to call the static function directly, which class should I address to, to avoid override layers as best as possible?

1 Answer 1


Use direct PHP function:

htmlspecialchars($row->tooltip, ENT_COMPAT, 'UTF-8');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.