|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41788 preg_replace_callback returns NULL instead of input or error
Submitted: 2007-06-24 11:44 UTC Modified: 2007-06-24 14:24 UTC
From: Sjon at hortensius dot net Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 5.2.3 OS: linux
Private report: No CVE-ID: None
 [2007-06-24 11:44 UTC] Sjon at hortensius dot net
The preg_replace_callback manual-entry says:

 If matches are found, the new subject will be returned, otherwise subject will be returned unchanged.

However; I have a testcase where no input is returned; and my callback isn't called either. This seems to be caused by a required pcre.backtrack_limit of 10000000

Shouldn't PHP return the input or an error giving some pointers about this limit being reached?

Reproduce code:
$input = '{?value==input.value}';
$regexp = '~\{\?(?:\(?!?.+(==)?.+\)?)+\}{\1\/}~sU';

var_dump(preg_replace_callback($regexp, 'callback', $input));

function callback(){

Expected result:
I expect an error to be raised when pcre.backtrack_limit is reached

Actual result:
NULL is var_dumped


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-24 14:24 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

See preg_last_error().
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Feb 20 22:01:28 2024 UTC