note 120098 deleted from function.fgetss by cmb
| From: | cmb@php.net | Date: | Mon, 07 Nov 2016 15:11:10 +0000 |
| Subject: | note 120098 deleted from function.fgetss by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207037@lists.php.net to get a copy of this message | ||
Note Submitter: Daniel Klein
----
The documentation doesn't specify how to use $allowable_tags. It's a string of tags in
HTML format, including the angle brackets.
<?php
$fh = fopen('somefile.txt', 'r');
$line = fgetss($fh, 1024, '<b><img>');
?>
This will strip all tags within the retrieved text EXCEPT <b> and <img>, keeping both
opening and closing tags. All attributes within the $allowable_tags are kept; you don't need to
specify them too. Partial tags are never included, even if they're in $allowable_tags, i.e. the
closing angle bracket must be present to be recognised.