我的网站上有一个头像上传插件,我在前端页面看到此代码错误...
警告:/xxx/xxx/xxx/media.php上遇到非数字值 第647行
第647行抛出错误的代码是:
$matched = ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 );
上面和下面的完整代码是:
// If the image dimensions are within 1px of the expected size, we consider it a match.
$matched = ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 );
任何帮助将不胜感激!
答案 0 :(得分:0)
这段代码为我解决了
// If the image dimensions are within 1px of the expected size, we consider it a match.
$matched = ( abs( (int)$constrained_size[0] - (int)$expected_size[0] ) <= 1 && abs( (int)$constrained_size[1] - (int)$expected_size[1] ) <= 1 );
答案 1 :(得分:-1)
尝试检查你的变量我认为你使用字符串作为整数。您可以插入日志或file_put_content来检查所有变量数据($ constrained_size和$ expected_size) 如果你确定你的变量是Integer然后尝试将它们转换为Integer,也许php将它们视为字符串无论如何 使用---&gt; (int)$ constrained_size和(int)$ expected_size