Home > Backend Development > PHP Tutorial > How to use the strip_tags function in php

How to use the strip_tags function in php

藏色散人
Release: 2023-04-06 19:14:01
Original
4791 people have browsed it

Usage of strip_tags function in php: [strip_tags(string,allow)]. The strip_tags function is used to strip HTML, XML and PHP tags from strings.

How to use the strip_tags function in php

php strip_tags function is used to strip HTML tags from strings. Its syntax is strip_tags(string,allow). The parameter string is required and is specified to be checked. The string, allow is optional and specifies the allowed tags.

(Related recommendations: php training)

How to use the php strip_tags function?

Function: Strip HTML tags in strings

Syntax:

strip_tags(string,allow)
Copy after login

Parameters:

string Required, specifies the characters to be checked string.

allow Optional, specifies allowed tags. These tags will not be deleted.

Description: The strip_tags() function strips HTML, XML and PHP tags from the string. This function always strips HTML comments. This cannot be changed via the allow parameter. This function is binary safe.

php strip_tags() function usage example 1:

<?php
echo strip_tags("<p>Hello <b>world!</b></p>","<b>");
?>
Copy after login

Output:

Hello world
Copy after login

php strip_tags() function usage example 2:

<?php
$i = "<b>hello<i> php.cn</i></b>";
$j = strip_tags($i,&#39;<i>&#39;);
echo $j;
?>
Copy after login

Output:

hello <i>php.cn</i>
Copy after login

The above is the detailed content of How to use the strip_tags function in php. For more information, please follow other related articles on the PHP Chinese website!

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