WP-lightbox 已弃用:preg_replace():/e 修饰符已弃用,请改用 preg_replace_callback
WP-lightbox Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
我的插件 wp-lightbox evolution 显示错误
Deprecated: preg_replace(): The /e modifier is deprecated, use
preg_replace_callback instead
当我将其替换为 preg_replace_callback
时出现错误:
Warning: preg_replace_callback(): Requires argument 2,
'stripslashes(strstr("", "class=") ? "[=14=]" : "")', to be a valid callback
如有任何帮助,我们将不胜感激。
此致
preg_replace
和 /e
修饰符用于接受 PHP 代码作为字符串。
preg_replace_callback
接受 callable。 preg_replace_callback
应该接受匹配数组的函数和 return 用作替换的字符串。
如果您不在其他任何地方使用此代码,使用匿名函数是有意义的,如下所示:
preg_replace_callback(YOUR_PATTERN_HERE, function ($matches) {
return stripslashes(
strstr($matches[1] . $matches[3], "class=")
? $matches[0]
: "");
}, YOUR_STRING_TO_BE_CHANGED_HERE);
查看问题 Replace preg_replace() e modifier with preg_replace_callback 了解更多信息。
我的插件 wp-lightbox evolution 显示错误
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
当我将其替换为 preg_replace_callback
时出现错误:
Warning: preg_replace_callback(): Requires argument 2, 'stripslashes(strstr("", "class=") ? "[=14=]" : "")', to be a valid callback
如有任何帮助,我们将不胜感激。
此致
preg_replace
和 /e
修饰符用于接受 PHP 代码作为字符串。
preg_replace_callback
接受 callable。 preg_replace_callback
应该接受匹配数组的函数和 return 用作替换的字符串。
如果您不在其他任何地方使用此代码,使用匿名函数是有意义的,如下所示:
preg_replace_callback(YOUR_PATTERN_HERE, function ($matches) {
return stripslashes(
strstr($matches[1] . $matches[3], "class=")
? $matches[0]
: "");
}, YOUR_STRING_TO_BE_CHANGED_HERE);
查看问题 Replace preg_replace() e modifier with preg_replace_callback 了解更多信息。