[eluser]Lone[/eluser]
As most of us on here are advanced php developers Im really curious to know what preferred way of echoing/setting variables/text people have. Do you prefer to use a single quote or double quote or a mixture of the two - and why?
Situation 1 - Echoing html/text
Personally, I use a mixture of the two when it comes to outputting html such as a repetitive table row eg.
Code:
function output_row($title,$value) {
echo "<tr>\n";
echo "\t".'<td class="title">'.$title.'</td>'."\n";
echo "\t".'<td>'.$value.'</td>'."\n";
echo "</tr>\n";
}
Sure its a lil bit more code, but if I use " then I have to use \ for setting tag variables like class and when there is a few it makes it hard to read. I hate unformatted html as well hence the \n and \t
The other alternative (which I use sometimes but fear the {} for some reason) I have seen is below:
Code:
function output_row($title,$value) {
echo "<tr>\n";
echo "\t<td class=\"title\">($title)</td>\n";
echo "\t<td>{$value}</td>\n";
echo "</tr>\n";
}
EDIT: () is meant to be {}
Situation 2 - Setting variables
I get into the habit now of setting variables using single quotes every now and again - but uncertain if there is a downside to this compared to "?
Code:
$text = 'some text';
As I said im more curious just to see what habits other people have formed and if there is any performance/memory/convention advantages or using one over the other?