I have this code: My old code is:
if (!file_exists($dirPath)) mkdir($dirPath, 0755,true); $target = "/".$mappe."/"; $target = $dirPath ."/". Basename( $_FILES<"gpsfilnavn"><"name">); $target = preg_replace("/(w+).gpx/ie","$1.".xml"",$target); $xmlfil = $xmlfil . Basename( $_FILES<"gpsfilnavn"><"name">); $xmlfil = preg_replace("/(w+).gpx/ie","$1.".xml"",$xmlfil); if(move_uploaded_file($_FILES<"gpsfilnavn"><"tmp_name">, $target)) { echo "The tệp tin ". Basename( $_FILES<"gpsfilnavn"><"name">)." has been uploaded";Can anybody help me what i have to change?
php
giới thiệu
Improve this question
Follow
asked Aug 26, năm 2016 at 9:56

compaccompac
2111 silver badge33 bronze badges
4
địa chỉ a bình luận |
2 Answers 2
Sorted by: Reset to default
Trending sort available
Introducing: Trending sort You can now choose lớn sort by Trending, which boosts votes that have happened recently, helping to lớn surface more up-to-date answers.
Bạn đang xem: Perform a regular expression search and replace
Trending is based off of the highest score sort và falls back to lớn it if no posts are trending.
Try it DismissHighest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)
2
There has been a change since PHP 7 regarding the preg_replace() function.According to lớn the man-page
7.0.0 tư vấn for the /e modifier has been removed. Use preg_replace_callback() instead.
Xem thêm: get length array php
Maybe this helps you?
nói qua
Improve this answer
Follow
answered Aug 26, năm nhâm thìn at 10:04

AudaxAudax
8111 silver badge44 bronze badges
add a comment |
1
I"ve stumbled upon this issue today when upgrading a phpBB-based trang web from PHP5 to lớn PHP7. I came up with three different workarounds that can be used for different scenarios, the second one being the only viable one for mine since I had template-based regexp stored within the filesystem/db instead of static ones, which I couldn"t easily alter.
Basically, I went from this:
$input = preg_replace($search, $replace, $input);to something like this:
$input = preg_replace($search, function($m) use ($replace) { $rep = $replace; for ($i = 1; $iNeedless khổng lồ say, this is nothing more than a quick-and-dirty workaround, only "viable" for those who cannot easily refactor their code with the updated preg_replace_callback function without having lớn use any potentially unsecure eval() call: for this very reason it should only be used if the developer has full control over the replacement strings/rules và is able to lớn properly test/debug them. That said, in my specific scenario, I was able to lớn effectively use that in order khổng lồ get the job done.
IMPORTANT: the str_replace and/or the eval() could break some replacement rules unless they are "properly" defined taking the above code into account.
For further info regarding this issue và other alternative workarounds you can also read this post on my blog.