strip_tags() function will return the string with stripped(removed) HTML and PHP tags.
<?php
$string = '<h2>This is PHP Rokcers blogspot.</h2><!-- Comment --> <a href="http://phprockers.blogspot.com/">phprockers</a>';
<?php
$string = '<h2>This is PHP Rokcers blogspot.</h2><!-- Comment --> <a href="http://phprockers.blogspot.com/">phprockers</a>';
echo strip_tags($string);
?>
Output:
=======
This is PHP Rokcers blogspot. phprockers
If we want to allow some specific tags in our string, we have to given that tags as parameters in strip_tags function.
<?php
$string = '<h2>This is PHP Rokcers blogspot.</h2><!-- Comment --> <a href="http://phprockers.blogspot.com/">phprockers</a>';
echo strip_tags($string, '<h2><a>');
?>
Output:
=======
<h2>This is PHP Rokcers blogspot.</h2><a href="http://phprockers.blogspot.com/">phprockers</a>
0 comments:
Post a Comment