Home > Backend Development > PHP Tutorial > PHP removes html tags-detailed explanation of the difference between strip_tags and htmlspecialchars_PHP tutorial

PHP removes html tags-detailed explanation of the difference between strip_tags and htmlspecialchars_PHP tutorial

WBOY
Release: 2016-07-21 15:02:47
Original
787 people have browsed it

strip_tags
 Remove HTML and PHP tags.
Syntax: string strip_tags(string str);
Return value: String
Function type: Data processing
Content description
This function can remove any HTML contained in the string and PHP tag strings. If the HTML and PHP tags of the string are originally wrong, for example, the greater than symbol is missing, an error will also be returned. This function has the same function as fgetss().

htmlspecialchars
Convert special characters into HTML format.
Syntax: string htmlspecialchars(string string);
Return value: String
Function type: Data processing
This function converts special characters into HTML string format (&. ...; ). The most commonly used occasion may be the message board for processing customer messages.
 & (and) is converted to &
  (double quotation marks) is converted to "
 < (less than) is converted to <
 > (greater than) is converted to>
 '' (Single quote) into '
This function only converts the above special characters, and does not convert all of them into the ASCII conversion specified by HTML.

Copy code The code is as follows:

$new = htmlspecialchars( "Test" , ENT_QUOTES);
echo $new ;
?>

Result: Test

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327899.htmlTechArticlestrip_tags Remove HTML and PHP tags. Syntax: string strip_tags(string str); Return value: String Function type: Data processing Content description This function can remove any...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template