CakePHP has a global function called h
. It's a convenience method for htmlspecialchars
. CakePHP also has a utility called Sanitize
, which has a method called html
. Here is part of its description:
This method prepares user-submitted data for display inside HTML. This is especially useful if you don’t want users to be able to break your layouts or insert images or scripts inside of your HTML pages.
When should each be used? Is one better than the other?