PHP/String/strip tags
Содержание
- 1 string strip_tags ( string html_text [, string allowed_tags] ) strips HTML and PHP tags from a string
- 2 Strip all except a few tags
- 3 Stripping HTML tags from a string
- 4 strip_tags
- 5 strip_tags() function, first argument is the text to transform.
- 6 strip_tags() function removes all HTML and PHP tags from string, leaving only the text entities.
- 7 strip_tags.php
string strip_tags ( string html_text [, string allowed_tags] ) strips HTML and PHP tags from a string
<?
$input = "<blink><strong>Hello!</strong></blink>";
$a = strip_tags($input);
$b = strip_tags($input, "<strong><em>");
?>
Strip all except a few tags
<?
$input = "I <b>love</b> to <a href = \"http://www.wbex.ru\">wbex<a>!";
$strip_input = strip_tags($user_input, "<a>");
print_r($strip_input);
?>
Stripping HTML tags from a string
<?
// Remove HTML from comments
$comments = strip_tags($_POST["comments"]);
print $comments.
?>
strip_tags
<?php
$input = "This <a href="http://www.wbex.ru/">example</a>!";
echo strip_tags($input, "<a>");
?>
strip_tags() function, first argument is the text to transform.
The second argument is optional and should be a list of HTML tags that strip_tags() can leave in place.
<?php
$string = "<p>I <i> will not have </i>it,";
$string .= "<br/>.</p><b>The end</b>";
print strip_tags( $string, "<br/>" );
?>
strip_tags() function removes all HTML and PHP tags from string, leaving only the text entities.
Its syntax is: string strip_tags (string string [, string allowable_tags])
<?
$user_input = "i just <b>love</b> PHP!";
$stripped_input = strip_tags($user_input);
print $stripped_input;
?>
strip_tags.php
<?php
$input = "I <td>really</td> love <i>PHP</i>!";
$input = strip_tags($input,"<i></i>");
echo $input;
?>