strip_tags() function in PHP


The strip_tags() function is used to strip HTML and PHP tags from a string.

Syntax

strip(str, allow)

Parameters

  • str − The string to check

  • allow − The allowable tags that won’t be removed (won’t be stripped).

Return

The strip_tags() function returns the stripped string.

Example

The following is an example −

Live Demo

<?php
   echo strip_tags("<p>Demo <strong>Text!</strong></p>");
?>

Output

Demo Text!

Example

The following is an example −

Live Demo

<?php
   echo strip_tags("<p>Demo <strong>Text!</strong></p>","<strong>");
?>

Output

Demo <strong>Text!>/strong>

Updated on: 30-Jul-2019

127 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements