Computer >> Computer tutorials >  >> Programming >> PHP

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 −

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

Output

Demo Text!

Example

The following is an example −

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

Output

Demo <strong>Text!>/strong>