2016-12-06 93 views
1

我建立了一些功能主題選項wordpress。Php7.1致命錯誤:[]運算符不支持字符串

但現在我收到以下錯誤,我究竟做錯了什麼?

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')"; 

Fatal error: [] operator not supported for strings in

什麼我漏掉的代碼?

+0

也許你想添加字符串已經是一個字符串'$ w_custom_font1_src的變種=「網址... 「' – 0x13a

+0

哪裏是$ w_custom_font1_src定義? – aynber

回答

3

你可能在某處所以現在重新初始化使用這個變量作爲$w_custom_font1_src作爲stringarray

$w_custom_font1_src = array(); 

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')"; 
相關問題