Add php variable inside echo statement as href link address?

前端 未结 5 1694
盖世英雄少女心
盖世英雄少女心 2020-12-02 18:55

I\'m trying to use a php variable to add a href value for a link in an echo statement.

Here\'s a simplified version of the code I want to use. I know that I can\'t j

相关标签:
5条回答
  • 2020-12-02 19:22

    as simple as that: echo '<a href="'.$link_address.'">Link</a>';

    0 讨论(0)
  • 2020-12-02 19:24

    Try like

    HTML in PHP :

    echo "<a href='".$link_address."'>Link</a>";
    

    Or even you can try like

    echo "<a href='$link_address'>Link</a>";
    

    Or you can use PHP in HTML like

    PHP in HTML :

    <a href="<?php echo $link_address;?>"> Link </a>
    
    0 讨论(0)
  • 2020-12-02 19:29

    you can either use

    echo '<a href="'.$link_address.'">Link</a>';
    

    or

    echo "<a href=\"$link_address\">Link</a>';
    

    if you use double quotes you can insert the variable into the string and it will be parsed.

    0 讨论(0)
  • 2020-12-02 19:36

    If you want to print in the tabular form with, then you can use this:

    echo "<tr> <td><h3> ".$cat['id']."</h3></td><td><h3> ".$cat['title']."<h3></</td><td> <h3>".$cat['desc']."</h3></td><td><h3> ".$cat['process']."%"."<a href='taskUpdate.php' >Update</a>"."</h3></td></tr>" ;
    
    0 讨论(0)
  • 2020-12-02 19:44

    Basically like this,

    <?php
    $link = ""; // Link goes here!
    print "<a href="'.$link.'">Link</a>";
    ?>
    
    0 讨论(0)
提交回复
热议问题