-4
我收到以下錯誤:警告:number_format()預計參數1雙待,串給出
Warning: number_format() expects parameter 1 to be double, string given in............. on line 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;
}
什麼是您發佈的代碼的第200行?除了自定義函數外,我在代碼中的任何地方都看不到'number_format()'......? – 2015-01-15 15:37:03
我看到太多這樣的問題。花時間學習如何[解釋錯誤並修復代碼](http://jason.pureconcepts.net/2013/05/fixing-php-errors/)。 – 2015-01-15 15:37:33
其空行。請告訴我解決方案,將其刪除。我會很高興。謝謝 – Ali 2015-01-15 15:38:17