html - navigation bar doesn't appear correctly, through php echo -
i'm sitting here in front of problem, unknown me.
when use normal html-code works. when use php-echo, navigation bar doesn't normally.
the bar supposed (here normal html code):
http://i.gyazo.com/1e5c02f7e20dff5ec55800f259ff2c8f.png
and php-echo looks this:
http://i.gyazo.com/693dd2a2ac7a333905e2aa90cc8cc147.png
and that's code snip html:
<div class="navibar"> <ul id="mainnavi"> <li><a href='index.php'>index</a></li> <li><a href='index.php'>index</a></li> <li><a href='index.php'>index</a></li> </ul> </div>
and here php-echos:
<div class="navibar"> <ul id="mainnavi"> <?php echo "<li><a href='index.php'>index</a></li>"; echo "<li><a href='index.php'>index</a></li>"; echo "<li><a href='index.php'>index</a></li>"; ?> </ul> </div>
so after hour found "error" , found solution:
instead of echo, used "\n" in end of line, this:
echo "<li><a href='index.php'>index</a></li>\n";
why work here , not normal echos? first time ever had problem... wrong here?
i hope code-snip enough now, if isn't i'll add more of code.
thanks!
first of all, you'd have understand little way unordered lists operate. syntactic structure of statement places each of <li>
items on same line. also, of course have use newline character \n
or <br>
line break element. otherwise php (and html matter) doesn't distinguish 1 line begins , ends, they'll run-on lines. that's beauty of php, , provides it's concatenation superpowers.
to fix dilemma , correct output <li>
elements partitioned in first screenshot, try including <ul>
tags in echo statements well.