In my HTML, does it matter which of these formats I use…
Option #1:
<ul id="topMenu">
Option #2:
<ul id='topMenu'>
When I write PHP, I tend to use this format in my echo statements…
echo "<ul id='topMenu'>";
…because it allows PHP to recognize embedded variables.
So for consistency, I guess I would prefer to use Option #2 when I have straight-HTML.
Does it really matter?
Sincerely,
Debbie
no. It functionally doesnt matter whether you enclose attributes in quotes or double quotes. Tho I can see how double quotes would go with the double D brand… (or did I get that backwards) lol
One PHP tip:
echo '<ul id="topMenu">';
echo '<ul id="', $id , '">';
is marginally faster than
echo "<ul id='topMenu'>";
echo "<ul id='$id'>";
According to the spec , it doesn’t matter. So it comes down to personal preference.
I personal prefer the double quotes, but I can understand why you’d want to do it your way (though there are other ways to accomplish the same thing)
Glad to hear I have options!
Ha ha!
dresden_phoenix:
One PHP tip:
echo '<ul id="topMenu">';
echo '<ul id="', $id , '">';
is marginally faster than
echo "<ul id='topMenu'>";
echo "<ul id='$id'>";
That is because things in single quotes in PHP are taken as literals and thus don’t need to be interpreted, right?
Sincerely,
Debbie
force
October 1, 2013, 9:48pm
5
When echoing HTML, I almost exclusively do it like this:
$linktext='Visit example.org today!';
echo '<a href="http://example.org">'.$linktext.'</a>';
This is to avoid having to escape characters, as that tends to get messy and introduces errors.
whut-evah yew wa-ont, so long’s you’s consistent
‘"’“'”
Apparently a little too much wine…
Debbie