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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2019 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 04:01:25 2019 UTC