PHP初记|strip_tags()函数

WBOY
Release: 2016-06-13 11:00:01
Original
687 people have browsed it

PHP小记|strip_tags()函数

定义和用法

strip_tags() 函数剥去 HTML、XML 以及 PHP 的标签。

语法

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

提示和注释

注释:该函数始终会剥离 HTML 注释。这点无法通过 allow 参数改变。

例子

例子 1

<?phpecho <code>strip_tags("Hello <b>world!</b>");?>
Copy after login

输出:

Hello world!
Copy after login

例子 2

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

输出:

Hello <strong>world!</strong>
Copy after login
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!