How to Use "strip_tags" string function?
Printable View
How to Use "strip_tags" string function?
The strip_tags() function is used to strips a string from HTML, XML, and PHP tags.
It has mainly two parameters
1) String:- specifies string to check
2) Allow:- specifies allowable tags and will not be removed
Syntax:-
strip_tags(string,allow)
Example:-
<?php
echo strip_tags("This is an example of strip tags");
?>
The output is: - This is an example of strip tags
You can get more idea at http://www.w3schools.com/php/func_string_strip_tags.asp
I think above mentioned way is best,
you have to follow this.
<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// Allow <p> and <a>
echo strip_tags($text, '<p><a>');
?>
http://php.net/manual/en/function.strip-tags.php
It is pretty simple and I don't think it needs any further explanation. If you still have any SPECIFIC issue, please make it clear.
<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// Allow <p> and <a>
echo strip_tags($text, '<p><a>');
?>
Awesome post about Liferay it's really great...