我想在我的网站上显示一个电话号码作为"电话链接"。 我在模板中使用以下PHP代码显示电话号码:
<?php if($employeeObj->getEmail() != "" && $employeeObj->getEmail() != "-"){ ?>
<tr>
<td colspan="2"><?=$employeeObj->getEmail()?></td>
</tr>
如何将电话号码实现为此 PHP 代码中的链接?
有人可以帮助我吗?
可以按如下方式完成:
<?php if($employeeObj->getEmail() != "" && $employeeObj->getEmail() != "-"){
$phone = str_replace("/", "", $employeeObj->getEmail());
$phone = str_replace(" ", "", $phone);
?>
<tr>
<td colspan="2"><a href="callto:<?= $phone ?>"><?= $phone ?><a/></td>
</tr>
<?php } ?>