Skip to content

Instantly share code, notes, and snippets.

@hugotkk
Created November 8, 2018 07:57
Show Gist options
  • Save hugotkk/e12e36237e3ef1d2bcc1084564f639c3 to your computer and use it in GitHub Desktop.
Save hugotkk/e12e36237e3ef1d2bcc1084564f639c3 to your computer and use it in GitHub Desktop.
#twig, #htmlspecialchars, #htmlspecialchars_decode
// Prevent html injection eg: <h1>hihi</h1>
$text = htmlspecialchars($text)
// twig default with prevent the html injection
{{ text }} -> &lt;h1&gt;hihi&lt;/h1&gt;
{{ text | raw }} -> <h1>hihi</h1>
// convert &gt; -> >, does not need unless you want to be hacked with html
htmlspecialchars_decode($text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment