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

How to use the strip_tags function in php

藏色散人
藏色散人Original
2019-05-23 16:49:064742browse

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)

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>");
?>

Output:

Hello world

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;
?>

Output:

hello <i>php.cn</i>

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!

Statement:
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