php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11594 preg_replace is not working with backslash $
Submitted: 2001-06-20 17:40 UTC Modified: 2001-08-06 13:01 UTC
From: PWMoosman at aol dot com Assigned:
Status: Closed Package: PCRE related
PHP Version: 4.0.5 OS: Solaris
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: PWMoosman at aol dot com
New email:
PHP Version: OS:

 

 [2001-06-20 17:40 UTC] PWMoosman at aol dot com
I'm trying to use preg_replace to replace $ with \$.

Here is a sample script:

<?

$data = '$_hello_$world';

$data = preg_replace('/\$/i','\$',$data);
print "data : $data\n";

?>


I expect the script to output \$_hello_\$world. However, version 4.0.5 is outputing $_hello_$world.

This worked in version 4.0.4

It possible this bug is related to bug# 10668


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-06 13:01 UTC] andrei@php.net
You need to use '\\\\$' as you replacement string.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Feb 23 08:01:25 2019 UTC