The htmlentities function takes a string and returns the same string with HTML converted into HTML entities. For example, the string would be converted to .
By converting the into entities, it prevents the browser from using it as an HTML element and it prevents the code from running if you were to display some user's input on your website.
This may seem a little complicated, but if you think of the way a browser works, in separate stages, it becomes a little easier. Let's look at the way the function htmlentities changes the data at three different levels: in PHP, in raw HTML and in the web browser. The sample string is a bad script that will redirect visitors to the malicious user's own website.
No comments:
Post a Comment