English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP srip_tags() Function Usage and Example

PHP String Manual of String Functions

    The srip_tags() function is used to remove HTML and PHP tags from a string.

Syntax

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

Definition and Usage

This function attempts to return the result of the given string str after removing whitespace characters, HTML, and PHP tags.

Return Value

 Returns the processed string.

Parameter

Serial NumberParameters and Description
1

string

Input String

2

allow

Use the optional second parameter to specify the list of characters not to be removed

Online Example

Try the following example, strip_tags deletes HTML tags and retains specified tags:

<?php
$text = '<p>PHP Tutorial</p><!-- Comment --> <a href="#fragment">www.oldtoolbag.com</a>'; 
//Delete all HTML tags
echo strip_tags($text);
echo "\n";
// Do not delete the <p> and <a> tags
echo strip_tags($text, '<p><a>');
?>
Test and See‹/›

Output Result

PHP Tutorial www.oldtoolbag.com
PHP Tutorial
www.oldtoolbag.com

PHP String Manual of String Functions