Jump to content

unknown output, how can i avoid it?


resolate

Recommended Posts

Hello,

 

I have some trouble in my code. For now i am trying to output an amortization table that i calculated inside a class. I achieve for the table to be outputted, but there is also an instance of ">>>>>" being outputted and i do not know from where... I have added an image below so you can see the output of the ">>>>".

 

Here's my code:

<?php

include './index.php';

$val = new Validator();

$input = new Input($val->getSanitized()['input-aw'], $val->getSanitized()['input-i'], $val->getSanitized()['input-n']);

$loanHL = new LoanHL($input);
$loanHL->calculate();

?>

<table class="table">
<thead>
<tr>
    <th>periode</th>
    <th>schuld</th>
    <th>aflossing</th>
    <th>waarvan intrest</th>
    <th>waarvan kapitaal</th>
    <th>restschuld</th>
</tr>
</thead>
    <tbody>
    <?php
    foreach ($loanHL->getCalculateData() as $key => $val)
    {
        echo '<tr>';
        echo '<td>' . $loanHL->getCalculateData()[$key]['period'] . '</td>>';
        echo '<td>' . $loanHL->getCalculateData()[$key]['aw'] . '</td>>';
        echo '<td>' . $loanHL->getCalculateData()[$key]['payment'] . '</td>>';
        echo '<td>' . $loanHL->getCalculateData()[$key]['intrestPayment'] . '</td>>';
        echo '<td>' . $loanHL->getCalculateData()[$key]['capitalPayment'] . '</td>>';
        echo '<td>' . $loanHL->getCalculateData()[$key]['debt'] . '</td>>';
        echo '</tr>';
    }

    ?>
    </tbody>
</table>

The calculatedata comes from the following two things:

    public function getCalculateData()
    {
        return $this->calculateData;
    }
public function calculate()
    {
        $annuity = $this->calcAnnuity($this->workData['aw'],$this->workData['i'],$this->workData['n']);
        for ($ii = 0; $ii < $this->workData['n']; $ii++)
        {
            $this->calculateData[$ii +1]['period'] = $ii + 1;
            $this->calculateData[$ii +1]['aw'] = $this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']);
            $this->calculateData[$ii +1]['payment'] = $annuity;
            $this->calculateData[$ii +1]['intrestPayment'] = $this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']) * $this->workData['i'];
            $this->calculateData[$ii +1]['capitalPayment'] = $annuity - ($this->calcAw($annuity,$this->workData['i'],$ii,$this->workData['n']) * $this->workData['i']);
            $this->calculateData[$ii +1]['debt'] = $this->calcAw($annuity,$this->workData['i'],$ii + 1,$this->workData['n']);
        }
    }

Appreciate all the help! Also some pointers on my design pattern are welcome, i am new to PHP OOP trying to get the hang of it

 

grtz,

 

Resolate

 

post-204469-0-33504200-1496658321_thumb.jpg

Link to comment
Share on other sites

OMG

 

i see it now... Thanks Jackques1.

 

Still it strikes me as a surprise that this code is printed above the table headings, since the ">" duplication is found beneath...

 

Any ideas on my design pattern? I especially have trouble creating my Validator class. There are many to be found as open source libraries, but the configuration makes my head explode with the knowledge i only have at this point...

 

And thanks for the link of the validater, i ll definately be using it :)

Link to comment
Share on other sites

Still it strikes me as a surprise that this code is printed above the table headings, since the ">" duplication is found beneath...

 

Because it is invalid HTML, there is no specification on how it should be displayed. You will likely get different results in different browsers. In this case you have content (the > character) that is between the table tags, but is not within any valid table elements (e.g. TD or TH). Since they aren't "in" the table the browser processor needs to decide what to do with them. Putting them before or after the table makes the most sense.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.