Which is better to use?

Started by Rich, February 09, 2014, 10:12:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rich

Many thanks for the above, I thought that my first example would have been wrong after looking through various files and was unsure on the other two?  Glad to know that either of the other two are acceptable and is more of a personal preference.

While the 2nd option could make it easier to see at a glance it obviously takes up more line space than the 3rd.

I just need to decide which one to use and stick with it!!

I fully understand what you mean about having consistency throughout the code and this is something that I'm working though to resolve, I even made a Crib Sheet so that I can refer to it to make sure I have everything in the correct order in every file.

Example.
<table class="NAME" border='0 or 1' align='left, center, right' width='16' height='16' cellspacing='0 - 10' cellpadding='0 - 10'>
    <tr class='table' align='left, center, right' valign='' <?php echo $VARIABLE?>>
        <td class='colhead or rowhead or ???' align='left, center, right' width='16' height='16' style='padding: 0px'>
            <label for='LABEL_NAME'>YOUR TEXT HERE</label>
            <input type='text, password, hidden' class='btn' name='NAME' id='LABEL_NAME' size='SIZE' value='' style='padding: 0px' />
            <textarea name='' id='' cols='' rows='' style=''>$VARIABLE</textarea>
        </td>
    </tr>
</table>

<form method='post or get' action='staffpanel.php?tool=adduser&amp;action=adduser'>
    <table class="NAME" border='0 or 1' align='left, center, right' width='16' height='16' cellspacing='0 - 10' cellpadding='0 - 10'>
        <tr class='table' align='left, center, right' valign='' <?php echo $VARIABLE?>>
            <td class='colhead or rowhead or ???' align='left, center, right' width='16' height='16' style='padding: 0px'>
                <label for='LABEL_NAME'>YOUR TEXT HERE</label>
                <input type='text, password, hidden' class='btn' name='NAME' id='LABEL_NAME' size='SIZE' value='' style='padding: 0px' />
                <textarea name='' id='' cols='' rows='' style=''>$VARIABLE</textarea>
            </td>
        </tr>
    </table>
</form>

elephant

Personally I would go with:


?><td class='rowhead' align='left'><?=$arr['txt']?></td><?

Mindless

First example is wrong, it has no quotes and will throw undefined constant errors -> $arr[text] should be ['text'] second example is fine and third example is my personal preference as you will have seen me do so since early Tbdev days, it's also noticeable in a lot of my work, in an ideal world you choose one method and stick with it for the sake of consistency however when there is a lot of contributors that's easier said than done lol.

Rich

No one? :(

Or is it a person preference which to use?

Rich

I'm changing some code and wanted opinions on which is better to use for the $arr and why or is their no difference?

<td class='rowhead' align='left'>$arr[txt]</td>

<td class='rowhead' align='left'>" . $arr['txt'] . "</td>

<td class='rowhead' align='left'>{$arr['txt']}</td>