警告:第123,124,125行/customers/1/2/3/websiteurl/httpd.www/wp-content/plugins/videonab/lib/plugin-classes/video.php中遇到非数字值
代码是(第123,124,125行)
public static function seconds_to_time( $seconds ){
$hours = floor($seconds / 3600); /* line no 123 */
$mins = floor(($seconds - ($hours*3600)) / 60);/* line no 124 */
$secs = floor($seconds % 60);/* line no 125 */
return array(
'hours' => $hours,
'minutes' => $mins,
'seconds' => $secs,
);
}
答案 0 :(得分:1)
请尝试检查is_numeric
或is_integer
,并在操作任何类型的计算之前将其转换为(int)
。
public static function seconds_to_time( $seconds ) {
if( is_numeric( $seconds ) ) {
$hours = floor( (int)$seconds / 3600);
$mins = floor(( (int)$seconds - ($hours*3600)) / 60);
$secs = floor( (int)$seconds % 60);
return array(
'hours' => $hours,
'minutes' => $mins,
'seconds' => $secs,
);
} else {
return array();
}
}
希望这个有用:)