How can the strip_tags() function be used to remove tags from a string in PHP?

To remove HTML tags from a string in PHP, you can use the strip_tags() function. This function takes a string as input and returns the string with all HTML tags removed. This is useful when you want to sanitize user input or display text without any formatting.

$string = "<p>This is a <b>sample</b> text with <a href='#'>HTML</a> tags.</p>";
$clean_string = strip_tags($string);
echo $clean_string;