HTML block nested in PHP if statement - is this considered bad practice?

Posted by JYelton on Stack Overflow See other posts from Stack Overflow or by JYelton
Published on 2011-01-10T17:44:40Z Indexed on 2011/01/10 17:53 UTC
Read the original article Hit count: 144

Filed under:
|
|

Consider the following example:

<table>
    <tr>
        <td>Row One</td>
    </tr>
    <?php
    if ($rowtwo)
    {
    ?>
    <tr>
        <td>Row Two</td>
    </tr>
    <?php
    }
    ?>
</table>

If $rowtwo is true, the second row is output, otherwise it is skipped.

The code works as desired, however I am evaluating Netbeans (7 beta) as a PHP IDE (instead of just using a text editor). Netbeans flags the code with an error:

Misplaced non-space characters insided [sic] a table.

Should I consider an alternate way of writing this code, or is Netbeans incapable of understanding this flow control wrapper for HTML output?

© Stack Overflow or respective owner

Related posts about php

Related posts about html