php - Fatal error: Can't use method return value in write context in empty() -
i getting following error why this?
fatal error: can't use method return value in write context
foreach ($transfer_nids $nid) { $wrapper = entity_metadata_wrapper('node', $nid); $result[] = array( 's_name' => empty($wrapper->field_s->value()->title) ? 'no data' : $wrapper->field_s->value()->title, 'r_name' => empty($wrapper->title->value()) ? 'no data' : $wrapper->title->value(), 'max' => empty($wrapper->field_max->value()) ? 'no data' : $wrapper->field_max->value(), ); } return ai_wrap_result($result, 'info'); }
in (older versions) of php (<5.5) can't use empty()
on return of function directly, compiler reasons.
what need instead save result in intermediary variable , check if empty()
instead, i.e.,
foreach ($transfer_nids $nid) { $wrapper = entity_metadata_wrapper('node', $nid); $rname = $wrapper->title->value(); $max = $wrapper->field_max->value(); $result[] = array( 's_name' => empty($wrapper->field_s->value()->title) ? 'no data' : $wrapper->field_s->value()->title, 'r_name' => empty($rname) ? 'no data' : $wrapper->title->value(), 'max' => empty($max) ? 'no data' : $wrapper->field_max->value(), ); } return ai_wrap_result($result, 'info');
Comments
Post a Comment