首页 > 解决方案 > Wordpress PHP 警告:遇到非数字值

问题描述

一段时间以来,我一直收到以下错误:

PHP Warning:  A non-numeric value encountered in /home/user/public_html/wp-content/themes/mytheme/content-one.php on line 29
PHP Warning:  A non-numeric value encountered in /home/user/public_html/wp-content/themes/mytheme/content-one.php on line 30

这些行是:

$minutes = floor($duration_in_seconds / 60);
$seconds = $duration_in_seconds % 60;

PHP版本:7.3.20

谁能帮我一些建议,如何解决这个问题?谢谢!

标签: phpwordpresserror-handling

解决方案


$duration_in_seconds可能是一个字符串,修复它的简单方法是执行以下操作:

$duration_in_seconds = intval($duration_in_seconds, 10)

推荐阅读