PHP htmlspecialchars, strip_tags, addslashes explanations

Source: Internet
Author: User

First function: Strip_tags, remove HTML and PHP tags

Note: This function removes any HTML and PHP tag strings that are contained in the string. If the string of HTML and PHP tags are wrong, for example, less than the symbol, it will also return errors. This function and FGETSS () have the same function. FGETSS is to read the file from the file and remove the HTML and PHP tags.

Second function: Htmlspecialchars, convert special characters to HTML format

In detail, this function converts characters

& (and) turn into &

"(double quotation marks) turn into "

< (less than) turn into &lt;

> (greater than) turn into &gt;

Third function: Htmlentities, convert all characters to HTML string

Maybe you're still sorry htmlspecialchars can only handle 4 HTML tags, now you do not regret, htmlentities is to convert all characters. Not all powerful, but it doesn't make much sense to me.

The fourth function: Stripslashes and addslashes are a pair, addslashes is using a backslash reference string, Stripslashes is a string that restores addslashes references.

This function is generally a necessary step before a database query, which is preceded by a backslash in order for the database query statement to be preceded by some characters. These characters are single quotes ('), double quotation marks ("), backslashes (\), and NUL (the NULL character).

PHP htmlspecialchars, strip_tags, addslashes explanations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.