Req #66299 [Opn->Csd]: General sugestion on the correct use function strip_tags
| From: | cmb@php.net | Date: | Thu, 23 Sep 2021 16:27:21 +0000 |
| Subject: | Req #66299 [Opn->Csd]: General sugestion on the correct use function strip_tags | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236785@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66299&edit=1
ID: 66299
Updated by: cmb@php.net
Reported by: m dot klemarczyk at live dot com
Summary: General sugestion on the correct use function
strip_tags
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Strings related
PHP Version: 5.5.7
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
$allowed_tags may be an array as of PHP 7.4.0.
Previous Comments:
------------------------------------------------------------------------
[2013-12-16 01:19:45] m dot klemarczyk at live dot com
Description:
------------
---
From manual page: http://www.php.net/function.strip-tags
---
I'm not opposed to the current way of using this function.
I think that should also behave similarly to how JS interprets tags. This functionality can be for
many people a very useful, for one simple reason, passed all structures specified tag.
Test script:
---------------
<?php // striptags.php
$data = '<br>Each<br/>New<br />Line';
$new = strip_tags($data, '<br>');
var_dump($new);
$data = '<br>Each<br/>New<br />Line';
$new = strip_tags($data, '<br/>');
var_dump($new);
$data = '<br>Each<br/>New<br />Line';
$new = strip_tags($data, '<br />');
var_dump($new);
$data = '<br>Each<br/>New<br />Line';
$new = strip_tags($data, array('br'));
var_dump($new);
$data = '<br>Each<br/>New<br />Line';
$new = strip_tags($data, array('BR'));
var_dump($new);
?>
Expected result:
----------------
// OUTPUTS string(21) "<br>EachNew<br />Line"
// OUTPUTS string(16) "Each<br/>NewLine"
// OUTPUTS string(11) "EachNewLine"
// OUTPUTS string(21) "<br>Each<br/>New<br />Line"
// OUTPUTS string(21) "<br>Each<br/>New<br />Line"
Actual result:
--------------
// OUTPUTS string(21) "<br>EachNew<br />Line"
// OUTPUTS string(16) "Each<br/>NewLine"
// OUTPUTS string(11) "EachNewLine"
// OUTPUTS string(11) "EachNewLine"
// OUTPUTS string(11) "EachNewLine"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66299&edit=1