Tags
Asked 3 years ago
9 Jun 2021
Views 239
ajamil

ajamil posted

strip_tags removing everything in php ?

strip_tags removing everything in php ?
kord

kord
answered Apr 25 '23 00:00

If strip_tags () is removing everything from your string, it's likely that your input string doesn't contain any valid HTML tags.

The strip_tags () function removes any HTML tags and their attributes from a string. If the input string doesn't contain any HTML tags, then the function will return an empty string.

Here's an example of how strip_tags () works:



// Input string with HTML tags
$input_string = '<p>This is some <strong>bold text</strong>.</p>';

// Remove all HTML tags
$filtered_string = strip_tags($input_string);

// Output the filtered string
echo $filtered_string;

In this example, the output will be:



This is some bold text.

However, if the input string doesn't contain any HTML tags, the function will return an empty string:



// Input string with no HTML tags
Post Answer