【发布时间】:2015-01-19 16:29:18
【问题描述】:
我正在尝试计算页面上的某些内容,测试回显工作正常,但不会显示在正确的“if”部分中。出于某种原因,它不断触发最后一个 else - 嗯? - 部分。在里面工作了几个小时后,我感到很困惑。
是的,我是 php 的新手...我敢肯定这是我在这里缺少的一些简单的东西。
<? $balance = number_format(($due - $paid), 2, '.', ''); ?>
<? echo $due; ?> -
<? echo $paid; ?> =
<? echo $balance; ?><br>
<? if (($balance = 0) AND ($paid = 0)) { ?>
<a href="createworkorder.php?id=<?=$id?>&step=4" title="This ticket has no charges."><strong>$<?=number_format(($balance), 2, '.', ''); ?></a></strong>
<? } elseif ($balance > 0) { ?>
<a href="createworkorder.php?id=<?=$id?>&step=4" title="Click to pay or print."><strong><font color="red">$<?=number_format(($balance), 2, '.', ''); ?></font></strong></a>
<? } elseif (($balance = 0) AND ($paid > 0)) { ?>
<a href="createworkorder.php?id=<?=$id?>&step=4" title="PAID IN FULL. Ready to close"><strong><font color="lime">$<?=number_format(($balance), 2, '.', ''); ?></font></strong></a>
<? } else { ?>
<a href="createworkorder.php?id=<?=$id?>&step=4" title="HUH??"><strong>$<?=number_format(($balance), 2, '.', ''); ?></a></strong>
<? } ?>
【问题讨论】:
-
你是在分配而不是比较。
标签: php if-statement echo