|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77789 Undocumented E_WARNINGs raised in invalid regexps
Submitted: 2019-03-24 11:00 UTC Modified: 2021-07-26 13:58 UTC
From: beebware at gmail dot com Assigned:
Status: Verified Package: *Regular Expressions
PHP Version: 7.3.3 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-03-24 11:00 UTC] beebware at gmail dot com
From manual page:

The documentation states:
Errors/Exceptions ΒΆ
As of PHP 5.5.0 E_DEPRECATED level error is emitted when passing in the "\e" modifier. As of PHP 7.0.0 E_WARNING is emitted in this case and "\e" modifier has no effect.

However, E_WARNING s are raised if the regular expression is invalid.

I feel that just adding a comment in the 'Errors/Exceptions' part of the documentation that 'E_WARNINGs will be raised if an error occurs. NULL will will be returned and preg_last_error will be populated.' will suffice, but ideally (and this would probably require a code change) a way of stopping the E_WARNINGSs being emitted would be the 'best solution'.

Test script:



Expected result:
No E_WARNING raised, but NULL to be returned and preg_last_error to be populated.

Actual result:
E_WARNING is raised (not documented), but NULL to be returned and preg_last_error to be populated.

Warning: preg_replace(): No ending delimiter '/' found in /in/ULXiT on line 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-26 13:58 UTC]
-Status: Open +Status: Verified
 [2021-07-26 13:58 UTC]
Right, that should be documented, although I'd consider passing an
invalid regex to these function a programming error.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 02 03:01:29 2024 UTC