PHPエラーのこと
Notice: Trying to access array offset on value of type null in
PHP v7.4から出たエラー。配列ではない変数を配列にした時に出る現象。今回(2021/12/08)は、カスタムフィールドACFを使用した際に出た。
解決方法は以下の通り。(現状ではこのパターン[2021/12/08])
// ↓ 基本的な解決方法
$value = array("test"=>null);
// ↓ ACFなどカスタムフィールドを使った場合の解決方法
$field_name = get_field('フィールド名')
if($field_name){
//処理
}参考サイト:PHP Notice: Trying to access array offset on value of type null in に対処


