John_A Posted November 3, 2016 Share Posted November 3, 2016 I have this snippet which is giving a deprecated warning re the "e" pattern modifier in PHP5.5: - $result = preg_replace("/\[^a-zA-Z0-9]/e"," ",$result);I'm not even sure what the "e" modifier does, as it's not my code...maybe something to do with removing duplicates? Anyway, what's the best way to replace this so that it doesn't give the warning in PHP5.5, and will work in PHP7.0.0? I've got a feeling this might work :- $result= preg_replace("/\[^a-zA-Z0-9]/"," ",$result);but feel I might have over-simplified it, and it maybe doesn't quite do the same thing? Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/302457-alternative-to-e-pattern-modifier-in-php55/ Share on other sites More sharing options...
Jacques1 Posted November 3, 2016 Share Posted November 3, 2016 When in doubt, check the manual. Not only does it explain exactly what the modifier does; it also provides alternatives. In your case, the modifier does absolutely nothing. Either it's a leftover from earlier code versions, or the person writing the code was seriously confused. Quote Link to comment https://forums.phpfreaks.com/topic/302457-alternative-to-e-pattern-modifier-in-php55/#findComment-1538904 Share on other sites More sharing options...
John_A Posted November 3, 2016 Author Share Posted November 3, 2016 Thanks for your reply Jacques1. I did check the manual before posting, and it says to use preg_replace_callback() instead. But if, as you say, the modifier in my code does nothing anyway, is my suggestion (i.e. to simply remove it) not the best approach in this case? Quote Link to comment https://forums.phpfreaks.com/topic/302457-alternative-to-e-pattern-modifier-in-php55/#findComment-1538905 Share on other sites More sharing options...
Solution Jacques1 Posted November 3, 2016 Solution Share Posted November 3, 2016 Just remove the modifer. The replacement operation itself looks strange, but that's another story. Quote Link to comment https://forums.phpfreaks.com/topic/302457-alternative-to-e-pattern-modifier-in-php55/#findComment-1538910 Share on other sites More sharing options...
John_A Posted November 3, 2016 Author Share Posted November 3, 2016 Just remove the modifer. The replacement operation itself looks strange, but that's another story. Thanks again. It's part of a URL building function...to replace any non-alphanumeric characters with spaces, which are in turn replaced with dashes or underscores in the next part... Quote Link to comment https://forums.phpfreaks.com/topic/302457-alternative-to-e-pattern-modifier-in-php55/#findComment-1538911 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.