Skip to content
Advertisement

Can I make php automatically escape HTML chars when using ?

I am using unescaped data for example some string " <>> ' blah.

This causes trouble when I do this:

JavaScript

Which results in:

JavaScript

Is there a way to tell php to call htmlspecialchars on everything before printing it to the html document using <?= ?> so I don’t have to call it manually every time?

Advertisement

Answer

No, this is not possible. But you could make a shortcut method that. For example like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement