English 中文(简体)
如何考虑放款的pen?
原标题:How do i take account for the pennies in php money?
  • 时间:2010-11-12 21:23:45
  •  标签:
  • php

Ok, i

$total_cost

which is equal to 529700

我需要价值5 297.00美元。

这一价值来自我的奇迹10,2 实地

现在,根据用户是否处于国家,我需要拿出2%的子和8.25%的航运。

让我们仅仅假设所有用户都是来自这个国家,那么,如何通过加拿大网站来保护这些用户。

例如,这是我的想法。

$subtotal = $total_cost * 0.02;
$shipping = $total_cost * 0.0825;
$new_total = $total_cost + $shipping + $subtotal;

但是,如果是印刷这种想法,则需要0美元。

<?php print "$". $new_total; ?>
问题回答

在测试你的法典时,我没有获得这一结果。

php > $total_cost=529700;
php > $subtotal = $total_cost * 0.02;
php > $shipping = $total_cost * 0.0825;
php > $new_total = $total_cost + $shipping + $subtotal;
php > print "$". $new_total;
$583994.25

你们是否确信最初的价值是你们所期望的?

You need to see where this code breaks down, and that the values you think you have are actually there.... What does this output look like?

echo "Total: ".$total_cost."<br />";

$subtotal = $total_cost * 0.02;
echo "Sub: ".$subtotal . "<br />";

$shipping = $total_cost * 0.0825;
echo "Shipping: ".$shipping . "<br />";

$new_total = $total_cost + $shipping + $subtotal;
echo "New Total: ".$new_total . "<br />";

在计算百分比时,你必须将其改为浮动点数,或将 in合数降至0。

$subtotal = $totalcost / 100.0 * 0.02;
$shipping = $totalcost / 100.0 * 0.0825;
$newtotal = $totalcost / 100.0 + $subtotal + $shipping;




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签