2

Im a little new to this, and this one issue is driving me mad..

The tag "?= $active[0] ?" on the

  • is getting printed rather than executed.

    Any pointers appreciated...

    $url = $_SERVER['REQUEST_URI'];
    $active = 'class=""';
    
    switch($url){
    
        case('/SSPCorporate/index.php'):
            $active[0] = ' class="active"';
        break;
    
        case('/SSPCorporate/about.php'):
        case('/SSPCorporate/our-customers.php'):
        case('/SSPCorporate/our-partners.php'):
        case('/SSPCorporate/our-clients.php'):
        case('/SSPCorporate/our-standards.php'):
        case('/SSPCorporate/our-awards.php'):
            $active[1] = ' class="active"';
        break;
    
        case('/SSPCorporate/solutions.php'):
            $active[2] = ' class="active"';
        break;
    
        case('/SSPCorporate/services.php'):
            $active[3] = ' class="active"';
        break;
    
        case('/SSPCorporate/sustainability.php'):
        case('/SSPCorporate/what-are-we-doing.php'):
        case('/SSPCorporate/what-can-you-do.php'):
        case('/SSPCorporate/what-we-support.php'):
        case('/SSPCorporate/references.php'):
            $active[4] = ' class="active"';
        break;
    
        case('/SSPCorporate/healthcare.php'):
            $active[5] = ' class="active"';
        break;
    
        case('/SSPCorporate/blog/'):
            $active[6] = ' class="active"';
        break;
    
        case('/SSPCorporate/contact.php'):
            $active[7] = ' class="active"';
        break;
    
    }
    

    ?>

    echo($url);
    
    ?>
    
    <nav>
      <ul class="clearfix">
        <li id="first" <?= $active[0] ?> <a href="index.php" class="Bold">Home</a></li>
        <li <?= $active[1] ?> <a href="about.php" class="Bold">About</a></li>
        <li <?= $active[2] ?> <a href="solutions.php" class="Bold">Solutions</a></li>
        <li <?= $active[3] ?> <a href="services.php" class="Bold">Services</a></li>
        <li <?= $active[4] ?> <a href="sustainability.php" class="Bold">Sustainability</a></li>
        <li <?= $active[5] ?> <a href="healthcare.php" class="Bold">Healthcare</a></li>
        <li <?= $active[6] ?> <a href="/blog/" class="Bold">Blog</a></li>
        <li id="last" <?= $active[7] ?> <a href="contact.php" class="Bold">Contact</a></li>
      </ul>
    </nav>
    
  • swinhoe
    • 23
    • 4