|  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
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: zane at zanehooper dot com
New email:
PHP Version: OS:


 [2010-06-01 06:02 UTC] zane at zanehooper dot com
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-01 09:40 UTC]
-Status: Open +Status: Feedback
 [2010-06-01 09:40 UTC]
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:

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]
-Status: Open +Status: Feedback
 [2010-06-02 08:04 UTC]
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:

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

echo 'The Quick Brown Fox Jumps Over The Lazy Dog';

// 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: Tue Mar 05 03:01:30 2024 UTC