Skip to content

Escaping

From magento 2.4 the escape method has changed.

Instead of doing this:

$block->escapeHtml();
We instead use:
$escaper->escapeHtml();
This is because the escape methods of blocks has been deprecated and instead replaced with direct calls to the Escaper class.

For code completion we include a new use statement in phtml files.

use Magento\Framework\Escaper;

/** @var Escaper $escaper */

Magento Docs