php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51961 ob_start w/ str_ireplace
Submitted: 2010-06-01 06:02 UTC Modified: 2013-02-18 00:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: zane at zanehooper dot com Assigned:
Status: No Feedback Package: Output Control
PHP Version: 5.2.13 OS: Apache
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zane at zanehooper dot com
New email:
PHP Version: OS:

 

 [2010-06-01 06:02 UTC] zane at zanehooper dot com
Description:
------------
I am making a bad word replacer using certain profanity settings. Basically, when 
I use str_ireplace inside of ob_start, a lot of the capitals on the page are 
removed (I didn't see any capitals added).

I'm not sure why it is happening, but I really need this fixed.

Test script:
---------------
function optimizeHTML( $html )
{
    $html = str_ireplace( $badwords_array, $replacement, $html );
    return $html;
}

ob_start( 'optimizeHTML' );

Expected result:
----------------
A regular page with $badwords_array replaced by $replacement

Actual result:
--------------
Some capitals on the page are removed

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-01 09:40 UTC] aharvey@php.net
-Status: Open +Status: Feedback
 [2010-06-01 09:40 UTC] aharvey@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2010-06-01 13:31 UTC] zane at zanehooper dot com
-Status: Feedback +Status: Open
 [2010-06-01 13:31 UTC] zane at zanehooper dot com
Okay, the full script with PHP tags:

<?php
function optimizeHTML( $html )
{
    $badwords_array = array(  );
    $replacement = '';
    
    $html = str_ireplace( $badwords_array, $replacement, $html );
    return $html;
}

ob_start( 'optimizeHTML' );
?>

This is CapItalized.

The I or C in CapItalized might be removed, as well as the T in This or The.
 [2010-06-02 08:04 UTC] aharvey@php.net
-Status: Open +Status: Feedback
 [2010-06-02 08:04 UTC] aharvey@php.net
That's still incomplete, since it doesn't include the actual array you're giving str_ireplace() (which is kind of important).

Honestly, I'm kind of inclined to suspect it's a problem in your code, rather than PHP, since the following code works for me on PHP 5.2:

<?php
function filter_output($text) {
    $adjectives = array('quick', 'brown');
    return str_ireplace($adjectives, '', $text);
}

ob_start('filter_output');
echo 'The Quick Brown Fox Jumps Over The Lazy Dog';
ob_end_flush();

// Should end up printing "The   Fox Jumps Over The Lazy Dog"
?>
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 16:01:31 2024 UTC