Skip to content

Instantly share code, notes, and snippets.

@ricardofiorani
Created October 1, 2014 13:51
Show Gist options
  • Select an option

  • Save ricardofiorani/7eaa70d647e61f25075c to your computer and use it in GitHub Desktop.

Select an option

Save ricardofiorani/7eaa70d647e61f25075c to your computer and use it in GitHub Desktop.
Exemplo de condição php em uma linha
<li>
<a href="<?= $this->url(array('servicos-interna')) ?>#ancora-conteudo" title="Importação e Exportação"
class="<?= ($this->paginaAtual == 'servicos-interna') ? 'active' : '' ?>">
Importação e Exportação
</a>
</li>
Note que o <?= é o mesmo que <?php echo, ou seja, você está dando um echo no retorno da condição, exemplo:
<?= ($this->paginaAtual == 'servicos-interna') ? 'active' : '' ?>
<li>
<a href="<?= $this->url(array('servicos-interna')) ?>#ancora-conteudo" title="Importação e Exportação"
class="<?php if ($this->paginaAtual == 'servicos-interna') echo 'active' ?>">
Importação e Exportação
</a>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment