[英]How to fix Trying to access array offset on value of type bool in
在 PHP 7.4 中,我收到此通知: Trying to access array offset on value of type bool in
if( $book_font ){
foreach ( $book_font as $key => $font ) {
if ( in_array( $font['face'], $all_google_fonts ) ) {
self::options_typography_enqueue_google_font( $font['face'] );
}
}
}
此行的注意事项:
if ( in_array( $font['face'], $all_google_fonts ) ) {
该错误意味着在foreach
循环中, $font
的一个或多个值是 boolean 而不是数组。
解决它的一种方法是使用null 合并运算符??
像这样:
if ( in_array( $font['face'] ?? '', $all_google_fonts ) ) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.