php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #21013 strip_tags doesn't work with regular HTML-Expression <br>
Submitted: 2002-12-14 11:42 UTC Modified: 2002-12-14 12:00 UTC
From: digex at web dot de Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.3.0RC3 OS: Windows XP, FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: digex at web dot de
New email:
PHP Version: OS:

 

 [2002-12-14 11:42 UTC] digex at web dot de
strip_tags doesn't work as expected.
When trying so trip <br>-tags, strip_tags doesn't strip anything. It maybe strips somewhere else, but not on my screen. :-)

Take this example code:
<?
$fin ="blabla<br>blabla";
$res =strip_tags($fin, "<br>");
echo $res;
?>

echo outputs blabla<br>blabla in the HTML-Source.

The solution is leaving the angle-brackets away like:
<?
$fin ="blabla<br>blabla";
$res =strip_tags($fin, "br");
echo $res;
?>

But this doesn't correspond with the Documentation at http://www.php.net/manual/en/function.strip-tags.php
Escaping with $res =strip_tags($fin, "\<br\>"); does it, but why?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-14 12:00 UTC] philip@php.net
From the docs:

"You can use the optional second parameter to specify tags which should not be stripped."

So, that parameter is named allowable_tags, not tags_to_remove
 [2002-12-14 12:33 UTC] digex at web dot de
Hehe, damn it. I was reading too fast over the Docu and it was actually "which should _NOT_ be stripped".
I was searching for a function that does a simple strip and Ididn't read that it already strips HTML-Tags. :P
Bogus of course. :D *g* :P
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 11:00:01 2025 UTC