How to put concatenated variable within an a?

1

I have this php line:

echo '<a href="?p=ultimasnoticias&pagina='.$i.'">'.$i.'</a>';

I need to put .$i. between <a>.$i.</a> in my html script, eg:

<nav>
  <ul>
    <li>
      <a>.$i.</a>
    </li>

How do I do this?

    
asked by anonymous 10.09.2018 / 02:52

2 answers

3

Easy.

<nav>
  <ul>
    <li>
      <?php echo '<a href="?p=ultimasnoticias&pagina='.$i.'">'.$i.'</a>'; ?>
    </li>

Another option would be:

<nav>
  <ul>
    <li>
        <a href="?p=ultimasnoticias&pagina=<?php echo $i; ?>"><?php echo $i; ?></a>
    </li>

I hope I have helped.

    
10.09.2018 / 03:00
2

To decrease the code can also be:

<nav>
<ul>
<li>
   <a href="?p=ultimasnoticias&pagina=<?=$i?>"><?=$i?> 
   </a>
</li>
    
10.09.2018 / 12:54