|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-05-20 14:31 UTC] mike@php.net
-Status: Open
+Status: Feedback
-Package: Regexps related
+Package: PCRE related
[2010-05-20 14:31 UTC] mike@php.net
[2010-05-20 16:04 UTC] dscotese at litmocracy dot com
-Status: Feedback
+Status: Open
[2010-05-20 16:04 UTC] dscotese at litmocracy dot com
[2010-06-08 14:30 UTC] felipe@php.net
-Status: Open
+Status: Bogus
[2010-06-08 14:30 UTC] felipe@php.net
[2010-06-08 14:32 UTC] felipe@php.net
-Status: Bogus
+Status: Open
[2010-06-08 14:32 UTC] felipe@php.net
[2010-06-08 14:51 UTC] salathe@php.net
[2010-06-08 15:01 UTC] salathe@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: salathe
[2010-06-08 15:01 UTC] salathe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
Description: ------------ Sometimes preg_replace([Array],[Array],$subject) returns null, but the error cannot be reproduced using preg_replace($problem_regex,$repl,$subject). My attempt to reproduce it showed that $problem_regex was not a problem - the replacement worked as designed. I actually removed it from the arrays and did it separately under the assumption that the regex engine might have been biting off more than it could chew. If I shortened $repl, I was able to get the array version to work, but since my $repl was longer, I moved it to a separate call. The docs for preg_replace do not mention preg_last_error. That should be mentioned right where it says it returns NULL on error. Test script: --------------- // You may need to create several more patterns and replacements to get an error // Just make sure they're all legitimate $contents = file_get_contents("textfile.txt"); $find = array('<td><'.'?php readfile("/var/www/www.domain1.com/html/templates/leftmenu2_lfl.txt"); ?'.'></td><td width="663"', '#(?:<table .{450,500})?<\?php\s+readfile[^<>]*?templates/footer(?:lamps)?.txt[\'";) ]*\s*\?'.'>.*#s'); $replace = array('<td>file_get_contents('whatever').'</td><td width="601"', file_get_contents('newFooter.txt')); echo preg_replace($find, $replace, $contents); Expected result: ---------------- When the arrays are large enough and/or the patterns are complicated enough, The output will be empty. The "bug" is that there's no documentation on how to find out why it's empty. Is there a way?