Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand htmlspecialchars, strip_tags and addslashes of PHP

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to understand PHP htmlspecialchars, strip_tags, addslashes", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's learn how to understand PHP htmlspecialchars, strip_tags, addslashes.

1. Function strip_tags: remove HTML and PHP tags

Note: This function removes any HTML and PHP markup strings contained in the string. Errors are also returned if the HTML and PHP tags of the string are wrong, such as missing greater than symbols. This function has the same function as fgetss(). Fgetss reads files from files and removes html and php tags.

2. htmlspecialchars converts special characters to HTML format

Specifically, this function converts the following characters:

& (and) turned into &

" (double quotes) to"

< (小于) 转成 < >

(greater than) converted to>

3. htmlentities converts all characters into HTML strings

You may regret that htmlspecialchars can only handle four html tags, but htmlentities converts all characters. It's not powerful, but it doesn't mean much to me.

4. The stripslashes and addslashes functions are a pair, addslashes refers to strings using backslashes, and stripslashes restores strings referenced by addslashes.

This function is usually a necessary step to be processed before a database query. The string is preceded by backslashes for database query statements and so on. These characters are single quotes ('), double quotes ('), backslashes (/), and NULs (NULL characters).

At this point, I believe that everyone has a deeper understanding of "how to understand PHP htmlspecialchars, strip_tags, addslashes". Let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report