问题
I get this error from this line can anyone tell me who can resolve this problem.
function format_numeric($str) {
if(empty($str) && $str!=0) return;
global $appearance_settings;
$decimals = $appearance_settings['number_format_decimals'];
$point = $appearance_settings['number_format_point'];
$th_separator = $appearance_settings['number_format_separator'];
$result = number_format($str, $decimals, $point, $th_separator); //THIS IS THE LINE WITH THE ERROR
return $result;
}
回答1:
Judging by your variable names you're passing a string into this function, but as the message says, number_format()
requires a double
.
You can force the issue by adding
$str = floatval($str);
as the first line of your function.
This assumes that your $str
variable contains something that can be coerced to a double
. If it doesn't you might see other errors.
来源:https://stackoverflow.com/questions/24642812/warning-number-format-expects-parameter-1-to-be-double-string-given