每次我尝试运行这个代码,都会有一个消息说:
Fatal error: Call to undefined function money_format()
有这个问题的线是:
$pricetotal = money_format("%10.2n", $pricetotal);
和
$cartTotal = money_format("%10.2n", $cartTotal);
你能解释一下这个原因吗?
$cartOutput = "";
$cartTotal = "";
$pp_checkout_btn = '';
$product_id_array = '';
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
$cartOutput = "
Your shopping cart is empty
";} else {
// Start PayPal Checkout Button
$pp_checkout_btn .= '
';
// Start the For Each loop
$i = 0;
foreach ($_SESSION["cart_array"] as $each_item) {
$item_id = $each_item['item_id'];
$sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
while ($row = mysql_fetch_array($sql)) {
$product_name = $row["product_name"];
$price = $row["price"];
$details = $row["details"];
}
$pricetotal = $price * $each_item['quantity'];
$cartTotal = $pricetotal + $cartTotal;
setlocale(LC_MONETARY, "en_US");
$pricetotal = money_format("%10.2n", $pricetotal);
// Dynamic Checkout Btn Assembly
$x = $i + 1;
$pp_checkout_btn .= '
';
// Create the product array variable
$product_id_array .= "$item_id-".$each_item['quantity'].",";
// Dynamic table row assembly
$cartOutput .= "
";$cartOutput .= '
' . $product_name . ' ';$cartOutput .= '
' . $details . '';$cartOutput .= '
$' . $price . '';$cartOutput .= '
';//$cartOutput .= '
' . $each_item['quantity'] . '';$cartOutput .= '
' . $pricetotal . '';$cartOutput .= '
';$cartOutput .= '
';$i++;
}
setlocale(LC_MONETARY, "en_US");
$cartTotal = money_format("%10.2n", $cartTotal);
$cartTotal = "
// Finish the Paypal Checkout Btn
$pp_checkout_btn .= '
';}
?>