2013-01-22 18 views
0

可能重複:
What does the PHP error message 「Notice: Use of undefined constant」 mean?使用未定義的常量的不isset補救

我有 「使用未定義的常量的」 消息時加載這一功能:

function awp_get_options($i){ 
    $i[selects][] = 'special_effects'; 
    $i[radios][] = array('js_library','sack');     
    $i[selects][] = 'effects'; 
    $i[checkboxes][] = 'no_load_library'; 

return $i; 
} 

我將它改爲:

function awp_get_options($i){ 
if(isset($i[selects])){ 
    $i[selects][] = 'special_effects'; 
    $i[selects][] = 'effects'; 
} 
if(isset($i[radios])) 
    $i[radios][] = array('js_library','sack'); 

if(isset($i[radios])) 
    $i[checkboxes][] = 'no_load_library'; 

return $i; 
} 

它仍然說使用未定義的常量。如何更正此代碼?

回答

1
function awp_get_options($i){ 
    $i['selects'][] = 'special_effects'; 
    $i['radios'][] = array('js_library','sack');     
    $i['selects'][] = 'effects'; 
    $i['checkboxes'][] = 'no_load_library'; 

return $i; 
} 

剩下的就什麼類型$i傳遞給函數。其他現在是正確的。

0

報價添加到您的數組鍵,如:

$i[selects] 

$i["selects"] 
//or 
$i['selects']