PHP7.1 致命错误: [] 运算符不支持字符串

4

我建立了一个wordpress主题选项的函数。

但是现在我收到了以下错误信息,我做错了什么?

  if(isset($thm_options['custom_font1_eot']))
    $w_custom_font1_src[] = "url('{$thm_options['custom_font1_eot']['url']}?#iefix') format('embedded-opentype')";

  if(isset($thm_options['custom_font1_woff']))   
    $w_custom_font1_src[] = "url('{$thm_options['custom_font1_woff']['url']}') format('woff')";

  if(isset($thm_options['custom_font1_ttf']))
    $w_custom_font1_src[] = "url('{$thm_options['custom_font1_ttf']['url']}') format('truetype')";

致命错误:[]运算符不支持字符串 是否有任何遗漏的代码?

也许您想将字符串附加到已经是字符串的变量中 $w_custom_font1_src .= "url..." - user4962466
$w_custom_font1_src 定义在哪里? - aynber
1个回答

11

你可能在程序的其他地方将变量$w_custom_font1_src用作字符串,现在需要重新初始化为数组

 $w_custom_font1_src =  array();

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接