简体   繁体   中英

i have got some error in inc.library.php, what is a number_format() expects parameter 1 to be double?

hallo i have some error in inc.library.php

what is a number_format() expects parameter 1 to be double ?

Warning: number_format() expects parameter 1 to be double, string given in /Applications/XAMPP/xamppfiles/htdocs/tes/library/inc.library.php on line 46

Warning: number_format() expects parameter 1 to be double, string given in /Applications/XAMPP/xamppfiles/htdocs/tes/library/inc.library.php on line 46

and i have 2 waring in browser

this code in inc.library.php

function format_angka($angka) {
    $hasil =  number_format($angka,0, ",",".");
    return $hasil;
}

format_number excpects first argument to be a number, not a string. To convert numeric string with decimal points to number you can use function floatval(numberic_string) .

 function format_angka($angka) {
    $hasil =  number_format(floatval($angka),0, ",",".");
    return $hasil;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM