jeudi 9 avril 2015

navigation bar doesn't appear correctly, through php echo

I'm sitting here in front of a problem, which is very unknown for me.


When I use normal HTML-Code everything works. When I use a php-echo, my navigation bar doesn't look normally.


The bar is supposed to look like this (here with normal HTML CODE):


http://ift.tt/1IOslxH


and with php-echo it looks like this:


http://ift.tt/1IOsktB


and that's the code snip with 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 with 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 almost an hour I found the "error" and found a solution:


Instead of just echo, I used "\n" in the end of the line, like this:



echo "<li><a href='index.php'>index</a></li>\n";


Why does it work here and not with normal echos? It is the first time I ever had this problem... What is wrong here?


I hope this code-snip is enough for now, if it isn't I'll add more of the code.


Thanks!





Aucun commentaire:

Enregistrer un commentaire