Warning: A non-numeric value encountered in theme functions.php

Warning: A non-numeric value encountered in functions.php

I am using php 7.1.31. I am using Linux Centos Server. I have also tried to type casting. but not worked. When I have changed php version to 5.6. Same code was working.

foreach ( $product_size as $k => $w ) {
$w = intval( $w );
if ( isset( $width ) && $width > 0 ) {
$h = round( $height * $w / $width );
} else {
$h = $w;
}
add_image_size( $k, $w, $h, $crop );
}

Warning: A non-numeric value encountered in theme/functions.php on line 165.
I am getting issue in

$h = round( $height * $w / $width );

I tried to change it to

$h = (int)( $height * $w / $width );

but still same warning is coming.

Read more here:: Warning: A non-numeric value encountered in theme functions.php

Leave a Reply

Your email address will not be published. Required fields are marked *