PHP uses number of integrated functions for working with HTML tags. The list of HTML tags related functions is shown below.

The HTML tags functions in PHP:

The strip_tags() function

The strip_tags() function is used to strip HTML and PHP tags from a string. This function tries to return all Null bytes, HTML and PHP tags from a given string.

Syntax for strip_tags()

string strip_tags ( string $str [, string $allowable_tags ] );

Example with strip_tags() functions

    $tags_sample = "<p>;Paragraph here...</p><!--Comments here...--><a href='#'>Link here...</a>";
    echo strip_tags($tags_sample); // Output: 'Paragraph here... Link here...'
    echo strip_tags($tags_sample, "a"); // Output: 'Paragraph here... <a href='#'>Link here...</a>
echo "</div>";

›› go to examples ››