1. <?php
  2. // Source: http://us2.php.net/filters
  3. // This code will only allow certain HTML tags --- <B>, <U>, and <I> in this example
  4.  
  5. $fp = fopen('php://output', 'w');
  6. stream_filter_append($fp, 'string.strip_tags', STREAM_FILTER_WRITE, "<b><i><u>");
  7. fwrite($fp, "<b>bolded text</b> enlarged to a <h1>level 1 heading</h1>\n");
  8. fclose($fp);
  9. /* Outputs: <b>bolded text</b> enlarged to a level 1 heading */
  10. ?>
  11.  
  12. <HR>
  13. Another way to do this:
  14. <HR>
  15.  
  16. <?php
  17. $fp = fopen('php://output', 'w');
  18. stream_filter_append($fp, 'string.strip_tags', STREAM_FILTER_WRITE, array('b','i','u'));
  19. fwrite($fp, "<b>bolded text</b> enlarged to a <h1>level 1 heading</h1>\n");
  20. fclose($fp);
  21. /* Outputs: <b>bolded text</b> enlarged to a level 1 heading */
  22. ?>