Question

I have a class that build my main navigation. Everything works fine except for the html output i get in the source code. In my class i got something like this:

public function getNav(){
   $output = "";
   foreach($nav as $key=>$value){
       $output .= "<li><a href='$value'>$key</a></li>\n";
   }
   return $output;
}

Then i show navigation in my template...

    <ul class="nav">
    <?php echo $site->getNav(); ?>
    </ul>

... and the html source look like this:

     <ul id="nav">
           <li><a href='index.php'><span>HOME</span></a></li>
<li><a href='page2.php'><span>PAGE 2</span></a></li>
<li><a href='page3.php'><span>PAGE 3</span></a></li>
     </ul>

This is probably irrelevant, i'm just trying to understand if i get this due to the double quoted or what...

Was it helpful?

Solution

This output has nothing to do with the doublequotes(except the linebreak, which you wouldn't have without them).

Are you sure that your template is

    <ul class="nav">
    <?php echo $site->getNav(); ?>
    </ul>

...and not

    <ul class="nav">
          <?php echo $site->getNav(); ?>
    </ul>

? That's the only mysterious thing I see.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top