PHP/String/strip tags

Материал из Web эксперт
Перейти к: навигация, поиск

string strip_tags ( string html_text [, string allowed_tags] ) strips HTML and PHP tags from a string

   <source lang="html4strict">

<?

   $input = "<blink>Hello!</blink>";
   $a = strip_tags($input);
   $b = strip_tags($input, "");

?>

 </source>
   
  


Strip all except a few tags

   <source lang="html4strict">

<? $input = "I love to <a href = \"http://www.wbex.ru\">wbex<a>!"; $strip_input = strip_tags($user_input, "<a>"); print_r($strip_input); ?>

 </source>
   
  


Stripping HTML tags from a string

   <source lang="html4strict">

<? // Remove HTML from comments $comments = strip_tags($_POST["comments"]); print $comments. ?>

 </source>
   
  


strip_tags

   <source lang="html4strict">

<?php

  $input = "This <a href="http://www.wbex.ru/">example</a>!";
  echo strip_tags($input, "<a>");

?>

 </source>
   
  


strip_tags() function, first argument is the text to transform.

   <source lang="html4strict">

The second argument is optional and should be a list of HTML tags that strip_tags() can leave in place. <?php

$string = "

I will not have it,"; $string .= "
.

The end";

print strip_tags( $string, "
" ); ?>

 </source>
   
  


strip_tags() function removes all HTML and PHP tags from string, leaving only the text entities.

   <source lang="html4strict">

Its syntax is: string strip_tags (string string [, string allowable_tags]) <?

   $user_input = "i just love PHP!";
   $stripped_input = strip_tags($user_input);
   print $stripped_input;

?>

 </source>
   
  


strip_tags.php

   <source lang="html4strict">

<?php

  $input = "I <td>really</td> love PHP!";
  $input = strip_tags($input,"");
  echo $input;

?>

 </source>