|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28119 ereg_replace require string casting?
Submitted: 2004-04-23 09:33 UTC Modified: 2004-04-23 17:58 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: vb_user at yahoo dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.5 OS: Windows 2003
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: vb_user at yahoo dot com
New email:
PHP Version: OS:


 [2004-04-23 09:33 UTC] vb_user at yahoo dot com
When i pass in ereg_replace a variable like this:

ereg_replace($pattern, $variable, $string);

and $variable is holding an integer value, then $string will be replace with blank, not the value hold in $variable. This only happen in Windows installation not Linux as i have used this many times.

Doing the following will fix the problem:

ereg_replace($pattern, (string)$variable, $string);

But does that mean PHP is now no long type tolerant?

Reproduce code:
$variable = 13;
$pattern = 'test';
$string = 'this is a test';
ereg_replace($pattern, $variable, $string);

Expected result:
this is 13

Actual result:
this is


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-23 17:58 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

When you pass a non-string value as the 'replace' to 
ereg_replace() function it converts the argument to a 
number and then to the character represented by that 
Number 13 gets converted to the \r, with which the word 
test is replaced in your test. 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 11:01:29 2024 UTC