Php 分析错误:语法错误,意外'';]?)(“和”x27;(T#u常量#u封装#u字符串)
我尝试用以下建议修复Wordpress后端WPML插件中的错误: 它不起作用,现在我得到了这个错误: 分析错误:语法错误,意外的“”]?)(“” (T_常量_封装_字符串)在 /home/sweetclebration.nl/public_html/sweetclebration.nl/wp-includes/functions.php 在线527 我将代码粘贴在functions.php的开头,当它不起作用时将其删除。我没有触及代码的这一部分,所以我不确定为什么现在会出现这种情况Php 分析错误:语法错误,意外'';]?)(“和”x27;(T#u常量#u封装#u字符串),php,wordpress,Php,Wordpress,我尝试用以下建议修复Wordpress后端WPML插件中的错误: 它不起作用,现在我得到了这个错误: 分析错误:语法错误,意外的“”]?)(“” (T_常量_封装_字符串)在 /home/sweetclebration.nl/public_html/sweetclebration.nl/wp-includes/functions.php 在线527 我将代码粘贴在functions.php的开头,当它不起作用时将其删除。我没有触及代码的这一部分,所以我不确定为什么现在会出现这种情况 functi
function wp_extract_urls( $content ) {
preg_match_all(
"#(["']?)("
. "(?:([w-]+:)?//?)"
. "[^s()<>]+"
. "[.]"
. "(?:"
. "([wd]+)|"
. "(?:"
. "[^`!()[]{};:'".,<>«»“”‘’s]|"
. "(?:[:]d+)?/?"
. ")+"
. ")"
. ")1#",
$content,
$post_links
);
$post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) );
return array_values( $post_links );
}
函数wp\u extract\u url($content){
预赛(
"#(["']?)("
.“(?:([w-]+:)?/?)”
.“[^s()]+”
. "[.]"
. "(?:"
.“([wd]+)|”
. "(?:"
.“[^`!()[]{};:”,«»“'s]|”
.“(?:[:]d+)/?”
. ")+"
. ")"
. ")1#",
$content,
$post_链接
);
$post_links=array_unique(array_map('html_entity_decode',$post_links[2]);
返回数组_值($post_链接);
}
第527行是
.“[^`!()[]{};:”,«»“'s]|”
如果这是一个愚蠢的问题,我很抱歉。我确实读过以前问过的其他类似问题,但没有找到我的答案。我真的希望这里的人能帮助我。提前谢谢你!你应该用反斜杠转义所有的
“
字符(作为正则表达式本身的一部分):
“#([“]”?)(“
变成
“#([\”]?)(“
以及:
“[^`!()[]{};:”,«»“'s]|”
变成:
. "[^`!()[]{};:'\".,<>«»“”‘’s]|"
“[^`!()[]{};:'\',«»''s]|”
这应该解决这个问题:
preg_match_all(
"#([\"']?)("
. "(?:([w-]+:)?//?)"
. "[^s()<>]+"
. "[.]"
. "(?:"
. "([wd]+)|"
. "(?:"
. "[^`!()[]{};:'\".,<>«»“”‘’s]|"
. "(?:[:]d+)?/?"
. ")+"
. ")"
. ")1#",
$content,
$post_links
);
preg\u match\u all(
"#([\"']?)("
.“(?:([w-]+:)?/?)”
.“[^s()]+”
. "[.]"
. "(?:"
.“([wd]+)|”
. "(?:"
.“[^`!()[]{};:'\',«»''s]|”
.“(?:[:]d+)/?”
. ")+"
. ")"
. ")1#",
$content,
$post_链接
);
该行中的填隙“标记需要转义。例如:
. "[^`!()[]{};:'\".,<>«»“”‘’s]|"
“[^`!()[]{};:'\',«»''s]|”
必须在正则表达式中转义引号字符。它被解析为字符串文字结尾。
. "[^`!()[]{};:'\".,<>«»“”‘’s]|"