PHP strip_tags() Function
In this chapter you will learn:
- Definition for PHP strip_tags() Function
- Syntax for PHP strip_tags() Function
- Parameter for PHP strip_tags() Function
- Return for PHP strip_tags() Function
- Example - Strip HTML tags
Definition
strip_tags()
can strip HTML and PHP tags from a string.
Syntax
PHP strip_tags() Function has the following syntax.
string strip_tags ( string html_text [, string allowed_tags] )
Parameter
Its first Parameter is the string to strip. The second parameter specifies a list of HTML tags you want to keep.
Return
PHP strip_tags() Function returns a string without HTML tags.
Example
Here are two examples of stripping out tags:
<?PHP//jav a 2 s.c om
$input = "<blink><strong>Hello from java2s.com!</strong></blink>";
$a = strip_tags($input);
print $a;
$b = strip_tags($input, "<strong><em>");
print $b;
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP stripcslashes() Function
- Syntax for PHP stripcslashes() Function
- Parameter for PHP stripcslashes() Function
- Return for PHP stripcslashes() Function
- Note for PHP stripcslashes() Function
- Example - Remove the backslash in front of "World!"
Home » PHP Tutorial » PHP String Functions