我越来越Syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$'
这是我使用
function wpse44503_filter_content($content) {
$regex = '#src=("|\')'.
'(/images/(19|20)(0-9){2}/(0|1)(0-9)/[^.]+\.(jpg|png|gif|bmp|jpeg))'.
'("|\')#';
$replace = 'src="'.get_site_url($2).'"';
$output = preg_replace($regex, $replace, $content);
return $output;
}
这是我得到的是错误的行代码$replace = 'src="'.get_site_url($2).'"';
任何人都可以帮助我解决它吗? 谢谢
究竟是'$ 2'? – 2012-03-05 18:06:16
$ 2是无效的PHP变量名称....“有效的变量名称以字母或下划线开头,后面跟着任意数量的字母,数字或下划线。” – 2012-03-05 18:06:42
您是否试图将第二个捕获组“$ 2”传递给该函数? (有趣的是,有多少人似乎错过了这个。) – BoltClock 2012-03-05 18:07:59