不推荐使用:preg_replace():phpmailer中不推荐使用/e修饰符 [英] Deprecated: preg_replace(): The /e modifier is deprecated in phpmailer

查看:101
本文介绍了不推荐使用:preg_replace():phpmailer中不推荐使用/e修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用class.phpmailer.php从本地服务器发送电子邮件,它在PHP版本为php5.3.4的本地服务器中处理得很好,但是在将PHP版本更新为5.5.4之后,它显示以下消息:

I am using class.phpmailer.php to send email from my local server, it's processing well in my local server with PHP version php5.3.4 but after I update PHP version to 5.5.4 it's showing the following message:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in class.phpmailer.php`

这是导致错误的行:

$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', "'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded);

推荐答案

尝试并替换:

$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',"'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded);

使用

$encoded = preg_replace_callback('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',function($m) { return '='.sprintf('%02X', ord(stripslashes($m[1]))); }, $encoded);

这篇关于不推荐使用:preg_replace():phpmailer中不推荐使用/e修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆