Q:

PHP link not appearing

I am trying to have the text "Facebook" to be a clickable link but for some reason it will not appear on the front-end. 
Snippet of Code:
function friend_contact() {

$healthcard = get_field('healthcard');
$facebook = get_field('facebook');
$phone = get_field('phone');
$fax   = get_field('fax');
$email = get_field('email');

$post_info = '';

if (isset($healthcard['url'])) {
    $img = get_stylesheet_directory_uri() . "/images/mail-icon.png";
    $post_info .= '<a class="healthcard" href="'.$healthcard['url'].'"><img src="'.$img.'" /> Download Contact</a>';
}

if (isset($facebook['url']) && isset($healthcard['url']) {
    $post_info .= ' | ';
}   

if (isset($facebook['url'])) {
$post_info .= '<a href="'.$facebook['url'].'"><i class="fa fa-facebook" style="color:blue"></i> Facebook</a>';
}

$post_info .= '<ul class="friend-contact">';
$post_info .= "<li>$email</li>";
$post_info .= "<li>p: $phone</li>";
$post_info .= "<li>f: $fax</li>";
$post_info .= "</ul>";

var_dump($facebook);    
var_dump(get_field('facebook'));

genesis_markup( array(
    'html5' => sprintf( '<div class="entry-meta">%s</div>', $post_info ),
    'xhtml' => sprintf( '<div class="post-info">%s</div>', $post_info ),
) );
}

Results of Dump:
string(21) "https://www.yahoo.com" string(21) "https://www.yahoo.com"

Alternative Code With ['url']:
if (isset($facebook) && isset($healthcard['url']) {
    $post_info .= ' | ';
}

if (isset($facebook)) {
    $post_info .= '<a class="facebook" a href="$facebook"><i class="fa fa-facebook"></i> Facebook</a>';
    }

I think the root of the problem is with the code bit, ['url']
Thank you in advance

A:

You echo your string with single quotes, thus it won't process the variable. That looks like it's between double quotes, but that is part of your string. So either make it 
$post_info .= '<a class="facebook" href="'.$facebook.'"><i class="fa fa-facebook"></i> Facebook</a>';

or reverse the quotes. 
$post_info .= "<a class='facebook' href='$facebook'><i class='fa fa-facebook'></i> Facebook</a>";

Edit: as to what's the better way, is another discussion. As long as you're consistent.

