ZendFramework / PHP-我乘以2个变量时出现问题

时间:2019-05-28 14:46:37

标签: php zend-framework

我必须将两个变量相乘,问题是当var是浮点数时,结果不考虑小数。

示例:
var1 = 4.75
var2 = 8

它给我32,应该是38。

我正在处理ZendFramework。有没有一个PHP函数来定义一个变量,如浮点数?

代码:

<?php if(isset($this->preparation)) : ?>
<?php $ldqlDecla = $ldqlConst = $ldcpDecla = $ldcpConst = $pemDecla = 
$pemConst = '-'; ?>
<?php $latdDecla = $latdConst = $attfDecla = $attfConst = '-'; ?>
<?php foreach($this->preparation as $prep) : ?>
    <?php if($prep['id_lib_prep'] == '50001') :?>
        <?php $ldqlDecla = $prep['nb_ex_decla']; $ldqlConst = 
  $prep['nb_ex_const']; ?> 
    <?php elseif($prep['id_lib_prep'] == '50002') :?>   
        <?php $ldcpDecla = $prep['nb_ex_decla']; $ldcpConst = 
   $prep['nb_ex_const']; ?> 
    <?php elseif($prep['id_lib_prep'] == '50004') :?>   
        <?php $latdDecla = $prep['nb_ex_decla']; $latdConst = 
 $prep['nb_ex_const']; ?> 
    <?php elseif($prep['id_lib_prep'] == '50005') :?>   
        <?php $attfDecla = $prep['nb_ex_decla']; $attfConst = 
$prep['nb_ex_const']; ?>
    <?php elseif($prep['id_lib_prep'] == '50003') :?>   
        <?php $pemExDecla = $prep['nb_ex_decla'] * $prep['nb_obj_decla']; 
$pemExConst = $prep['nb_ex_const']?> 
        <?php $pemObjDecla = $prep['nb_obj_decla']; $pemObjConst = 
$prep['nb_obj_const']; ?> 
    <?php endif; ?>
<?php endforeach; ?>
<?php endif ?>

,然后在此处显示值:

<table border="1" class="tableModeFacturation">
    <thead>
        <tr>
            <th class="center">LDQL</th>
            <th class="center">LDCP</th>
            <th class="center">PEM</th>
            <th class="center">LATD</th>
            <th class="center">ATTF</th>
            <th class="center">TOTAL (hors PEM)</th>
        </tr>
    </thead>
    <tbody>
        <tr class="even">
            <td class="center">
                <?php echo $ldqlDecla; ?>
            </td>
            <td class="center">
                <?php echo $ldcpDecla; ?>
            </td>
            <td class="center"><?php echo $pemExDecla . ' / ' . $pemObjDecla; ?></td>
            <td class="center">
                <?php echo $latdDecla; ?>
            </td>
            <td class="center">
                <?php echo $attfDecla; ?>
            </td>
            <td class="center"><?php echo $total = $ldqlDecla + $ldcpDecla + $latdDecla + $attfDecla; ?></td>
        </tr>
    </tbody>
</table>

0 个答案:

没有答案