strip_tags() function will Strip HTML and PHP tags from a string.
Note : In PHP 5.3.4 and later versions, self-closing XHTML tags are ignored. You should use only non-self-closing tags in allowable_tags. For example, to allow both <br> and <br/>, you should use:
<?php
strip_tags($input, ‘<br>’);
?>
It returns the stripped string with leftover tags which are in allowable_tags.
[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, Description
PHP 5.3.4, This ignores self-closing XHTML tags in allowable_tags.
PHP 5.0 , The start and length parameters was added in this version.
PHP 4.3, HTML comments are always stripped.
[/table]
<?php echo "In below example only bold(b) and paragraph(p) tags are allowed."; echo strip_tags("<p>Hi from <b><i>Tutorialmines</i></b>.</p>","<b><p>"); echo strip_tags("<!--Testing comments --><p>Comment tag is always stripped off.</p>","<p>"); echo strip_tags("Php tags are <b>always stripped off</b>.<?php echo 'hdfg jdfgj g';?>","<b>"); ?>
Output of above code in the browser is as below:
In below example only bold(b) and paragraph(p) tags are allowed.Hi from Tutorialmines.
Comment tag is always stripped off.
Php tags are always stripped off.
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…