php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66299 General sugestion on the correct use function strip_tags
Submitted: 2013-12-16 01:19 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: m dot klemarczyk at live dot com Assigned:
Status: Open Package: Strings related
PHP Version: 5.5.7 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-12-16 01:19 UTC] 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"

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 15 13:01:35 2019 UTC