Functions for removing HTML tags in PHP

Source: Internet
Author: User
Strip_tags

Remove HTML and PHP tags.

Syntax:String strip_tags (string Str );

Return Value: String

Correspondence type: Data Processing

 

Description

This function removes any HTML and PHP tag strings contained in the string. If the HTML and PHP tags of a string are incorrect, for example, if a greater symbol is missing, an error is returned. And this function and
Fgetss () has the same functions.

Htmlspecialchars

Convert special characters to HTML format.

Syntax:String htmlspecialchars (string );

Return Value: String

Correspondence type: Data Processing

 

Description

This function converts special characters into the string format of HTML (&....;). The most common use case may be the message board for handling customer messages.

 

  • & (And) to & amp;
  • "(Double quotation marks) to & quot;
  • <(Less than) to & lt;
  • > (Greater than) to & gt;

This function only converts the preceding special characters and does not convert all the characters to the ASCII conversion specified in HTML.

 

Example

This is an example of Y Pipeline provided by aulbach@unter.franken.de (27-Jan-1999? Bytes/n?
@ Registrant
<Form action = '../B' La> isn't there e? M

<H2> restaurant description <H2>} 8 bytes 1/=?
Name of restaurant: @ brief author #?
<Input type = text name = "restname" value = "<? Hml labels? {

Echo htmlspecialchars ($ restname);?> ">

<! -- The variable $ restname is $ restname = "/" the white horse/""; --> phantom F? Why?
<Br> release 0fw 7 release
Enter the description (if HTML is used, you can use it directly): <br> cannot parse into D?

<Textarea name = "descript"> <? 9? & P? Bytes

Echo htmlspecialchars ($ descript); NV limit 5 Condor

?> </Textarea> 1 ta taobaoyun u

<Input type = submit> B? G?
</Form>

 

Htmlentities

Convert all the elements into HTML strings.

Syntax:String htmlentities (string );

Return Value: String

Correspondence type: Data Processing

 

Description

This function is a bit like the htmlspecialchars () function, but this function converts all strings into Special Character Set strings in HTML. However, there will be a lot of troubles in reading the original webpage code after conversion, especially when the text in the original webpage code becomes invisible to the cloud, and what you see on the browser is still normal.

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.