note 128908 added to function.strip-tags
| From: | PatrickdotJanseratGmail at main dot php dot net | Date: | Thu, 21 Sep 2023 13:48:17 +0000 |
| Subject: | note 128908 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220867@lists.php.net to get a copy of this message | ||
CAUTION: I noticed that strip_tags(), tested on PHP 8.2.10, will NOT work if you have some spaces
between the "<" and the tag name, which is still considered as valid HTML. So this can
get very problematic depending on your HTML source. Example:
<?php
$html = <<<END_OF_HTML
<p>This will be ok.</p>
< p >But this will not!< / p >
END_OF_HTML;
$output = strip_tags($html);
var_export($output);
?>
Will output: 'This will be ok.
< p >But this will not!< / p >'
It might be safer to use a proper filtering library such as http://htmlpurifier.org/ or to do it with a DOM parser.
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 213.55.172.109)
----
Manual Page -- https://php.net/manual/en/function.strip-tags.php
Edit -- https://main.php.net/note/edit/128908
Del: integrated -- https://main.php.net/note/delete/128908/integrated
Del: useless -- https://main.php.net/note/delete/128908/useless
Del: bad code -- https://main.php.net/note/delete/128908/bad+code
Del: spam -- https://main.php.net/note/delete/128908/spam
Del: non-english -- https://main.php.net/note/delete/128908/non-english
Del: in docs -- https://main.php.net/note/delete/128908/in+docs
Del: other reasons-- https://main.php.net/note/delete/128908
Reject -- https://main.php.net/note/reject/128908
Search -- https://main.php.net/manage/user-notes.php