What function in PHP can be used to remove HTML tags from a string?
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. It can be useful when you want to display user-generated content as plain text without any formatting.
$string_with_html = "<p>This is a <b>sample</b> text with <a href='#'>HTML</a> tags.</p>";
$clean_string = strip_tags($string_with_html);
echo $clean_string;
Related Questions
- How can the nl2br function be effectively used in PHP to handle line breaks in user-submitted text?
- How can different character encodings affect the use of urlencode in PHP?
- What are the advantages and disadvantages of storing data in text files versus using a database like MySQL for dynamic content?