Reputation: 694
I have noticed a very strange PHP behavior, where echo function seems to affect the styling of some elements on the page.
when I use:
echo "<ul>";
echo "<li><a class='item'><span class='item-icon'></span>Item-1</a></li>";
echo "<li><a class='item'><span class='item-icon'></span>Item-2</a></li>";
echo "</ul>";
I get "item-icon" slightly out of position.
But when I use this I get correct icon positions:
echo "<ul>";
?>
<li><a class="item"><span class="item-icon"></span>Item-1</a></li>
<li><a class="item"><span class="item-icon"></span>Item-2</a></li>
<?php
echo "</ul>";
I can still fix the css and use the first syntax, but I am very curious to know what is causing this porblem!!
Answer: Thanks to Brad Kent, adding line break to the echo fixed the problem!!
echo "<ul>";
echo "<li><a class='item'><span class='item-icon'></span>Item-1</a></li>\r\n";
echo "<li><a class='item'><span class='item-icon'></span>Item-2</a></li>\r\n";
echo "</ul>";
Upvotes: 2
Views: 114
Reputation: 5098
depending on what CSS is being applied...
version A contains no line breaks between the <li>
s
version B does contain line breaks betwen the <li>
s
<li>blah</li><li>blah</li>
vs
<li>blah</li>
<li>blah</li>
it can make a difference
Upvotes: 2
Reputation: 2027
Missing =
in this line?
v
echo "<li><a class'item'><span class='item-icon'></span>Item-1</a></li>";
Single quotes are okay.
Upvotes: 1