first off, I am a trainee as an IT specialist in a large company. We are working with PHP and MySQL the most. I have several years of experience in webdesign, so I have developed my own style of coding, of course.
Yesterday, I was blamed by my boss for having a bad coding style. Since I am working with a custom CMS here, I have to adapt to their coding style a little, of course. But sometimes, I just refuse to do just that, because I do not see any advantage in particular code parts. This is a short example of what I did:
<div id="news">
<?php
foreach ($news as $k=>$v) {
$v["Datum"]=strftime("%d.%m.%Y", strtotime($v["Datum"]));
?>
<div class="news_entry">
<div class="news_title"><span><?php echo $v["Headline"];?></span><span class="news_date"><?php echo $v["Datum"];?></span></div>
<div class="news_content"><?php echo $v["Detail"];?></div>
</div>
<?
}
?>
</div>
It is a small widget to display the recent news, nothing special, really. Since my boss had never seen this style of coding yet, he said it was really bad to code like this. I should rather adapt to his style:
<?php
$table.="<table class='sn' border=1 cellspacing=0>";
$table.="<tr><td class='ueberschrift' colspan='4'>Detail Informationen</td></tr>";
$table.="<tr><td class='us_blau_l'>Material Nr.</td><td>".$erg[1][komponente]."</td>
<td class='us_blau_l'>Sollzeit</td><td>".$erg[1][response_at]." Tage</td></tr>";
$table.="<tr><td class='us_blau_l'>iKLE:</td><td>".$erg[1][ikle]."</td><td class='us_blau_l'>Netzplan Std.:</td>
<td>".$erg[1][np_std]." h</td></tr>";
echo $table;
?>
He did not tell me why this is better (and I don't see it for myself either), so I am asking you. These examples are not the same, of course, but it is a whole different style (for me, at least) on how to output HTML within a PHP file.
Thanks you for reading so far, I will appreciate any comment of you.