PHP strips HTML from the string with XML and PHP tags function strip_tags ()

Source: Internet
Author: User

Instance

Peel the HTML tags from the string:

<?phpecho strip_tags ("Hello <b>world!</b>");? >

Definition and usage

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.

Grammar

Strip_tags (String,allow)
Parameters Describe
String Necessary. Specifies the string to check.
Allow Optional. Specifies the allowable label. These tags are not deleted.

Technical details

return value: Returns the stripped string
php version: update log: Since PHP 5.0, this function is binary safe.
since PHP 4.3, the function will always strip HTML comments.

More examples

Example 1

Strip the HTML tags from the string, but allow <b> tags to be used:

<?phpecho strip_tags ("Hello <b><i>world!</i></b>", "<b>");? >

The first parameter is required, which is to remove the source data for HTML and PHP tags, and the second parameter is optional, indicating that no filtering is required.

For example:

<?php$data = ' <a href= '/words?citype=0 > New Thesaurus </a> ' echo $data; Echo ' <br> '; Echo strip_tags ($data);? >

Output |:

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.