Detailed explanation of string filtering strip_tags() function example in php

strip_tags — strips HTML and PHP tags from strings, very important function
(PHP 4, PHP 5, PHP 7)
string strip_tags ( string $str [, string $allowable_tags ] )
$str: Input string.
$allowable_tags: optional, specifies a list of characters not to be stripped.
Role: Strip HTML, XML and PHP tags from strings.

Return Value: Returns the stripped string. 

<?php
$str = '<p><a href="jinsanguo.com" title="jinsanguo"><b><i>I am from Jinsanguo</i></b></a></p>' ;
echo strip_tags($str);	
//When right-clicking to view the source code, the output: I am from Jin Sanguo
echo strip_tags($str,"<a>");
//When right-clicking to view the source code, the output: <a href="jinsanguo.com"
echo strip_tags($str,"<p> <b>");
//When right-clicking to view the source code, the output: <p><b>I am from Jin Sanguo</b></p>
echo strip_tags($str,"<p> <b> <a>");
//When right-clicking to view the source code, the output: <p><a href="jinsanguo.com" title="Jin Sanguo"><b>I am from Jinsanguo</b></a></p>
?>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326711206&siteId=291194637