警告:number_format() 期望参数 1 为双精度,字符串给定


Warning: number_format() expects parameter 1 to be double, string given in

我收到以下错误:

警告:number_format() 期望参数 1 为双精度,字符串以............给出。在线 200

请告诉我解决方案。下面我已经发布了我的整个代码,直到第 200 行

<?php
function my_session_start() {
    session_start();
}
function escape($str) {
    $clean_str = ( get_magic_quotes_gpc ()) ? mysql_real_escape_string(stripslashes(trim($str))) : mysql_real_escape_string(trim($str));
    return $clean_str;
}
function _addslashes($str) {   
    $clean_str = ( get_magic_quotes_gpc ()) ? $str : addslashes($str);
    return $clean_str;
}
function clean($str) {
    $clean_str = stripslashes (trim($str));
    return $clean_str;
}
function checkbox_value($str) {
    if(isset($_POST[$str]) && $_POST[$str]=="on") return 1;
    return 0;    
}
function generate_random() {
    $str = md5(uniqid(rand(),1));
    return $str;
}
function html_link($str) {
    $str=correct_href($str);
    $ret='<a href="'.$str.'">'.$str.'</a>';
    return $ret;
}
function correct_href($str) {
    if(!trim($str)) return;
    if(strcmp(substr($str,0,7),"http://") && strcmp(substr($str,0,8),"https://")) $str="http://".$str;
    return $str;
}
function correct_number_format($str) {
    $app = new appearance();
    $appearance = $app->getAll();
    $decimals = $appearance['number_format_decimals']; 
    $point = $appearance['number_format_point'];  
    $separator = $appearance['number_format_separator']; 
    $ereg_str = "/^[0-9]*".$point."*[0-9]+".$separator."*[0-9]*$/";
    $ereg_str = str_replace(".", "'.", $ereg_str);
    if(preg_match($ereg_str, $str)) return 1;
    return 0;    
}
function correct_numeric($str) {
    global $appearance_settings;
    $point = $appearance_settings['number_format_point'];
    $separator = $appearance_settings['number_format_separator'];
    // replace 
    $str = str_replace($point,"#",$str);
    $str = str_replace($separator,"",$str);
    $str = str_replace("#",".",$str);
    return $str;
}
function correct_price($str) {
    global $appearance_settings;
    $point = $appearance_settings['price_format_point'];
    $separator = $appearance_settings['price_format_separator'];
    // replace 
    $str = str_replace($point,"#",$str);
    $str = str_replace($separator,"",$str);
    $str = str_replace("#",".",$str);
    return $str;    
}
在发生这种情况

的format_price($str)或format_int($str)中,我将进行以下更改:

$result = number_format($str, $decimals, $point, $th_separator);

$result = number_format((int)$str, $decimals, $point, $th_separator);

如果数字包含便士使用

$result = number_format((float)$str, $decimals, $point, $th_separator);