Warning: number_format() expects parameter 1 to be

2020-04-10 04:23发布

I got this Error on my Page slider:

Warning: number_format() expects parameter 1 to be double, string given in /home/globalar/public_html/wp-content/themes/automotive_s1/includes/slider.php on line 30

<?php

    if $str = floatval($str); ($post->post_type == "gtcd") {
        the_title();
    if (isset( $fields['price'])) {
        echo ' | <span class="price_slider">'.'  '.$symbols['currency']; 
        echo number_format($fields['price']).'</span> ';
    } else { 
        echo '';
}

标签: php wordpress
3条回答
地球回转人心会变
2楼-- · 2020-04-10 04:44

You should check what value is inside $fields['price'].

Just do:

var_dump($fields['price']);

It's possible you have some spaces or , instead of .

查看更多
祖国的老花朵
3楼-- · 2020-04-10 04:49
$fields['price']='8, 9858';
echo number_format((float)$fields['price']);

use (float) to parse correct way

查看更多
SAY GOODBYE
4楼-- · 2020-04-10 04:51

fix it with define other variabel.

$tot=$row['total'];
$total=number_format($tot,2);

$tot2=$tot*1;
$vat=number_format($tot2*10/100,2);

maybe help

查看更多
登录 后发表回答