In PHP 7.4 i'm getting this notice: 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'] );
}
}
}
Notice for this line:
if ( in_array( $font['face'], $all_google_fonts ) ) {
The error means in foreach
loop, one or more value of $font
is a boolean instead of an array.
One way to fix it is by using null coalescing operator ??
like this:
if ( in_array( $font['face'] ?? '', $all_google_fonts ) ) {
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.