PHP/File Directory/fgetss

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

fgetss.php

 
<?php
   $tags = "<h2><h3><p><b><a><img>";
   $fh = fopen("article.html", "rt");
   while (!feof($fh)) {
      $article .= fgetss($fh, 1024, $tags);
   }
   fclose($fh);
   $fh = fopen("article.html", "wt");
   fwrite($fh, $article);
   fclose($fh);
?>



fgetss() strips all HTML and PHP tags from the file: string fgetss (int filepointer, int length [, string allowable_tags])

 
<?
$fh = fopen("data.txt", "r");
while (!feof($fh)) :
   print fgetss($fh, 2048);
endwhile;
fclose($fh);
?>



Stripping all but a select few tags from an HTML file

 
<?
$fh = fopen("data.txt", "r");
$allowable = "<br>";
while (!feof($fh)) :
    print fgetss($fh, 2048, $allowable);
endwhile;
fclose($fh);
?>