Home > Backend Development > PHP Tutorial > PHP strip_tags() function to remove HTML, XML and PHP tags from strings, strip_tagsxml_PHP tutorial

PHP strip_tags() function to remove HTML, XML and PHP tags from strings, strip_tagsxml_PHP tutorial

WBOY
Release: 2016-07-12 08:50:34
Original
975 people have browsed it

PHP strip_tags() function to remove HTML, XML and PHP tags in strings, strip_tagsxml

strip_tags definition and usage

The strip_tags() function strips HTML, XML and PHP tags from a string.

Comments: This function always strips HTML comments. This cannot be changed via the allow parameter.

Note: This function is binary safe.

Grammar
strip_tags(string,allow)

参数 描述
string 必需。规定要检查的字符串。
allow 可选。规定允许的标签。这些标签不会被删除。

Technical details

Return value: Returns the stripped string.
PHP version: 4
Update log:
返回值: 返回被剥离的字符串。
PHP 版本: 4
更新日志:

自 PHP 5.0 起,该函数是二进制安全的。

自 PHP 4.3 起,该函数始终会剥离 HTML 注释。

As of PHP 5.0, this function is binary safe.

As of PHP 4.3, this function always strips HTML comments.

strip_tags instance 1,
<&#63;php
echo strip_tags("Hello <b>world!</b>");
&#63;>
Copy after login

Strip HTML tags from a string:

Results

Hello world! ,


Example 2

<&#63;php
echo strip_tags("Hello <b><i>world!</i></b>","<b>");
&#63;>
Copy after login
Strip HTML tags from a string but allow tags:


Results

Hello world!

http://www.bkjia.com/PHPjc/1133113.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1133113.htmlTechArticle
PHP strip_tags() function to remove HTML, XML and PHP tags in strings, strip_tagsxml strip_tags definition and usage strip_tags () function strips HTML, XML and PHP from strings...
Related labels:
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