PHP mailto:带有faicon内联的变量

this code is suppose to see if the ACF variable is empty if not prints html code of globe fa icon with mailto: variable called mail yet its not working any ideas?


<?php 
if((the_field('Email'))!=""){
    $mail = the_field('Email');
   echo '<a href="mailto:'.$mail.'"><i class="fa fa-envelope-o fa-2x"></i></a>'; 
}
?>

It is the basic thing there is the difference between get_field and the_field.

the_field print the data and get_field required echo to print the value. Assuming the meta key name is Email. Use below code

  <?php 
if(get_field('Email')!=""){
    $mail = get_field('Email');
   echo '<a href="mailto:'.$mail.'"><i class="fa fa-envelope-o fa-2x"></i></a>'; 
}
?>

I don't quite get the question but can you try:

<?php 
if((the_field('Email'))!=""){
    $mail = the_field('Email');
   echo '<a href="mailto:'.$mail.'"><i class="fa fa-envelope-o fa-2x">'.$mail.'</i></a>'; 
}
?>

as i can see the_field is a function and this function return a mail caracters so the return about the_fileld('email') is Null, i think that mean your problem is into this function.