This article introduces you to the content of PHP four security filter function summary (with code), there is a certain reference value, the need for friends can refer to, I hope to help you.
1. Stripslashes () function
Stripslashes () The main function is to remove the backslash
<?phpecho stripslashes ("Who\ 's Bill Gates?");? >
Output Result:
Who ' s Bill Gates?
2. Htmlentities () function
Htmlentities () converts a character to an HTML entity
<?php$str = "<?" W3s?h???? > Echo htmlentities ($str);? >
The HTML output of the above code is as follows (see source code):
<! DOCTYPE html>
The browser output of the above code:
<? W3s?h???? >
3. Htmlspecialchars () function
Convert pre-defined characters "<" (less than) and ">" (greater than) to HTML entities:
<?php$str = "This is some <b>bold</b> text."; echo Htmlspecialchars ($STR);? >
The HTML output of the above code is as follows (see source code):
<! DOCTYPE Html>
The browser output of the above code:
This is some <b>bold</b> text.
4. Strip_tags () function
Peel the HTML tags from the string:
The Strip_tags () function strips the HTML, XML, and PHP tags from the string.
Note: This function always strips HTML comments. This cannot be changed by the Allow parameter.
Note: This function is binary safe.
<?phpecho strip_tags ("Hello <b>world!</b>");? >
Hello world!
Related articles recommended:
PHP Implementation Method Summary (code) for extracting numbers in a string
What is the difference between the Echo statement and the print statement in PHP5