小编use*_*751的帖子

使用PHP的货币转换器

我是PHP的新手所以我不确定我做错了什么,但似乎只有最后一句如果声明正在执行,无论我选择哪种货币,美元兑换美元.

我需要这样做才能转换我选择的FROM和TO货币,转换会显示在amount_output框中.并且我输入的货币和挂载仍保留在结果中而不会重置.

任何帮助它非常感谢.

<?php                
$amount_input = filter_input(INPUT_POST, 'amount_input');
$currency1 = filter_input(INPUT_POST, 'currency1');
$currency2 = filter_input(INPUT_POST, 'currency2');

if ($currency1="CAD" AND $currency2="CAD")
{
    $amount_output = $amount_input*1.0;
}

if ($currency1="CAD" AND $currency2="EUR")
{
    $amount_output = $amount_input*0.624514066;
}       

if ($currency1="CAD" AND $currency2="GBP")
{
    $amount_output = $amount_input*0.588714763;
}       

if ($currency1="CAD" AND $currency2="USD")
{
    $amount_output = $amount_input*0.810307;
}       
if ($currency1="EUR" AND $currency2="CAD")
{
    $amount_output = $amount_input*1.601244959;
}

if ($currency1="EUR" AND $currency2="EUR")
{
    $amount_output = $amount_input*1.0;
}       

if ($currency1="EUR" AND $currency2="GBP")
{
    $amount_output = $amount_input*0.942676548;
}       

if …
Run Code Online (Sandbox Code Playgroud)

php currency converter calculator

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

calculator ×1

converter ×1

currency ×1

php ×1