如何在php中回显这个href?

<a href="<?php echo $row["snap"];">Snapchat</a>

Hey, so i'm building a basic program where it displays the users snapchat link from the database, I basically have everything finished(Data insertion, editing, displaying the link etc).

The only problem I have is that I can echo the snapchat for each row as php, but if the user doesnt enter their link it still displays the href tag, I basically just need it to just display the link only when the user enters the info. I have that all sorted out once again but I need a way to echo this in php.

You can do that like this:

<a <?php echo (isset($row["snap"]) && !empty($row["snap"])) ? "href='".$row['snap']."'" : ""; ?> >Snapchat</a>

Try this. Solves the issues with " and '

<a <?php echo !empty($row['snap'])?'href="'.$row['snap'].'"' : ''; ?> >Snapchat</a>

If you need to show the link only when user had a snapchat, then you need to put the if around the whole statement, otherwise you will get an empty link:

if (!empty($row["snap"])) {
    echo '<a href="'.$row["snap"].'">Snapchat</a>';
}

If you wish to display something else, in case there is no snapchat, just add else to it:

if (!empty($row["snap"])) {
    echo '<a href="'.$row["snap"].'">Snapchat</a>';
} else {
    // echo 'no snapchat';
}