admin管理员组

文章数量:1392110

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.

Code is look like this

    $width        = 300;
            $height       = 300;
            $crop         = 1;
            if ( function_exists( 'wc_get_image_size' ) ) {
                $size   = wc_get_image_size( 'shop_catalog' );
                $width  = isset( $size['width'] ) ? $size['width'] : $width;
                $height = isset( $size['height'] ) ? $size['height'] : $height;
                $crop   = isset( $size['crop'] ) ? $size['crop'] : $crop;
            }    

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.

本文标签: Warning A nonnumeric value encountered in theme functionsphp