if里面的值可以为null

  $abc = $form_state->getValue('abc')[0]['value'];
  if($abc == 'abc'){
    drupal_set_message('aa');
  }

$form_state->getValue('abc')[0]['value']
这个值是不存在的情况下也不会报错的
if()也不会报错的
也就是说if()判断里面的左边不一定要是有效的值

原文地址:https://www.cnblogs.com/qinqiu/p/8303085.html