php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12042 $ can't be escaped when using ereg function
Submitted: 2001-07-11 05:46 UTC Modified: 2001-07-11 05:51 UTC
From: teocl at globalsources dot com Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 4.0.6 OS: LINUX
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: teocl at globalsources dot com
New email:
PHP Version: OS:

 

 [2001-07-11 05:46 UTC] teocl at globalsources dot com
Please see the codes below:
<?

$arrfile = '<?include("$DOCUMENT_ROOT/TEMPLATES/TOP-BANNER.HTM");?>';

if(eregi("<\?include\(\"\$DOCUMENT_ROOT/TEMPLATES/TOP-BANNER\.HTM\"\);\?>",$arrfile))
        print "good\n";
else
        print "bad\n";

?>

The result will return "bad" because the eregi can't find the expression in the $arrfile. If I removed the $, it will return "good". I guess "$" can't be escaped inside the eregi function. Please help.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-11 05:51 UTC] zak@php.net
This is known and expected behavior.  Please review the regex docs more carefully - also search the php-general mailing list archives.

The quick fix is to place 3 backslashes in front of the $.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 04 15:01:28 2024 UTC