|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13559 parser misinterprets ?> in a regexp
Submitted: 2001-10-05 05:50 UTC Modified: 2001-10-09 16:59 UTC
From: cech at debian dot org Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.0.6 OS: Debian
Private report: No CVE-ID: None
 [2001-10-05 05:50 UTC] cech at debian dot org
From Debian bug #114345

When presented with a perfectly valid regular expression that contains ?> in
it, these characters are confused with those used to close a block of php code
in the html file. 


   // $article = preg_replace("/<([^>]*)(\s+[^>]*)?>/s",
   //                        '',
   //                        $article);

    Even though this entire block is commented out, I still get a parse error due to the ?> in the regexp. 

    The workaround seems to be use of the x modifier, and putting whitespace between the ? and >, like so...

$article = preg_replace("/<([^>]*)(\s+[^>]*)? >/xs",


P.S. cannot there be a mail reportin interface?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-09 14:47 UTC]
Intended behaviour.
From the docs (
"The 'one-line' comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first."
 [2001-10-09 16:59 UTC]

$article = preg_replace("/<([^>]*)(\s+[^>]*)?>/xs",

goes perfectly right, as it should.

KISS example:

$myvar = "ab?>cd";

should work (and does work). Inside strings everything is allowed, when you place // before the line, that string protection obviously doesn't work anymore.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Nov 30 10:01:27 2023 UTC