Open In App

PHP strip_tags() Function

The strip_tags() function is an inbuilt function in PHP which is used to strips a string from HTML, and PHP tags. This function returns a string with all NULL bytes, HTML, and PHP tags stripped from a given $str.

Syntax: 



string strip_tags( $str, $allowable_tags ) 

Parameters: This function accepts two parameters as mentioned above and described below: 

Return Value: This function Returns the stripped string.



Exceptions:  

Below programs illustrate the strip_tags() function in PHP: 

Program 1:  




<?php
  
// PHP programme to illustrate 
// strip_tags function without $allow parameter
echo strip_tags("Hello <b>GeeksforGeeks!</b>");
?>

Output: 
Hello GeeksforGeeks!

 

Program 2: 




<?php
  
// PHP programme to illustrate 
// strip_tags function with $allow parameter
  
echo strip_tags("Hello <b><i>GeeksforGeeks!</i></b>", "<b>");
?>

Output
Hello <b>GeeksforGeeks!</b>

Related Articles: 

Reference: http://php.net/manual/en/function.strip-tags.php
 

Article Tags :