treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Unexpected T_Class on line 12

  • Can anyone lend a hand?

    Line 12:

      <li class="find<?php echo ($page->isOpen()) ? ' active">' : ?>">Find</li>
    
  • Try:

      <li class="find <?php echo ($page->isOpen() ? 'active'); ?>">Find</li>
    
  • @TheDoc I got the following

      syntax error, unexpected ')'
    

    I ended up solving it by doing this:

      <?php foreach($pages->invisible()->slice(1, 1) AS $p): ?>
           <li class="<?php echo html(str::lower($p->title())) ?><?php echo ($p->isOpen()) ? ' active' : '' ?>"><?php echo html($p->title()) ?></li>
      <?php endforeach ?>
    
  • <?php echo ($p->isOpen()) ? ' active' : '' ?>
    

    Any reason for the ternary operator?

    <?php if($p->isOpen()) echo ' active' ?>
    
  • @BenWalker Thank you!!! I literally just copied it from the foreach statement above it with just a few alterations.