Jump to: navigation, search

Php strip tags

From w3cyberlearnings

Contents

PHP function strip_tags

This function strips HTML and PHP tags from a string.

Syntax strip_tags

  • string: string input.
  • keep: tags will not be removed.
strip_tags(string, keep)

Return

Return a string without all those backslashes.

Example 1

<?php

$str = "<p>God</p>";
echo 'original string:'. $str;
echo 'strip_tags: '.strip_tags($str);
?>

Output: '|' is the space makes by the HTML tag <p>

original string:
  |
God
  | 
strip_tags: God

Example 2: Do not remove the <p>

<?php

$str = "<p>God</p>";
echo 'original string:'. $str;
echo 'strip_tags: '.strip_tags($str,'<p>');
?>


Output: '|' is the space makes by the HTML tag <p>

original string:
|
God
|
strip_tags:
|
God
|

Related Functions


Navigation
Web
SQL
MISC
References