Skip to content

Instantly share code, notes, and snippets.

@DominicWatts
Last active September 12, 2024 13:56
Show Gist options
  • Save DominicWatts/300d2dd995d442870014d1dde3405516 to your computer and use it in GitHub Desktop.
Save DominicWatts/300d2dd995d442870014d1dde3405516 to your computer and use it in GitHub Desktop.
Magento 2 : Escaping phtml #magento2
public function escapeHtml($data, $allowedTags = null)
public function escapeHtmlAttr($string, $escapeSingleQuote = true)
public function escapeUrl($string)
public function encodeUrlParam($string)
public function escapeJs($string)
public function escapeCss($string)
$block->escapeHtml(__(""));
<?= $block->escapeHtml(__("")); ?>
$block->escapeHtmlAttr(__(""));
<?= $block->escapeHtmlAttr(__("")); ?>
$block->escapeUrl($block->getUrl('this/and/that'));
<?= $block->escapeUrl($block->getUrl('this/and/that')); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment