0

Possible Duplicate:
What does the PHP error message “Notice: Use of undefined constant” mean?

I got "use of undefined constant" message when load this function:

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 changed it to:

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;
}

It still says use of undefined constant. How to correct this code?

Community
  • 1
  • 1
Jenny
  • 1,729
  • 4
  • 19
  • 37

2 Answers2

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;
}

The rest is up to what type is $i given to a function. Other is correct now.

Davit
  • 1,394
  • 5
  • 21
  • 47
0

add quotes to your array keys like:

$i[selects]

to

$i["selects"] 
//or 
$i['selects']
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162