Task #4881
PHP5.5 : preg_replace(): The /e modifier is deprecated
Status: | Resolved | Start date: | 04/18/2014 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | dethegeek | % Done: | 0% | |
Category: | - | |||
Target version: | - |
Description
With php 5.5, some warnings appear when answering to a form :
18-04-2014 08:12 Deprecated function(8192): preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead Backtrace : /media/adelaunay/f8300cb9-ce6d-419c-bd74-5040e0102657/www/clients/1026/inc/toolbox.class.php:490 Toolbox::userErrorHandlerNormal() /media/adelaunay/f8300cb9-ce6d-419c-bd74-5040e0102657/www/clients/1026/plugins/formcreator/front/form.helpdesk.php:159 preg_replace()
After some tests, i suggest the below code :
$chaine = preg_replace_callback("#\[url\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/url\]#si", function($matches) { return '<a href=\"'.$matches[1]. str_replace(' ', '%20', $matches[3]).'\">'. $matches[1].$matches[3].'</a>'; }, $chaine);
instead preg_replace l158
History
#1 Updated by dethegeek about 8 years ago
- Status changed from New to Resolved
- Assignee set to dethegeek
Escaping a double quote is useless when the string is between single quotes.
Implemented in a very similar way in revision 114