Raf Posted January 22, 2023 Share Posted January 22, 2023 Hello. I need to add clickable phone number and mail. I learn html and js, so.... Can You help? <?php if(!empty($header_email)): ?> <li> <span><i class="fa <?php echo esc_attr($header_email_icon);?>"></i></span> <?php echo esc_html($header_email);?> </li> <?php endif; ?> <?php if(!empty($header_phone)): ?> <li> <span><i class="fa <?php echo esc_attr($header_phone_icon);?>"></i></span> <?php echo esc_html($header_phone);?></li> <?php endif; ?> I added the code, but It dosen't work. <a href="<?=$header_phone?>"><?=$header_phone?></a> Can You help? Regards and thank You Quote Link to comment https://forums.phpfreaks.com/topic/315824-clickable-phone-number-and-mail-in-php/ Share on other sites More sharing options...
ginerjm Posted January 22, 2023 Share Posted January 22, 2023 (edited) I think that I replicated your code. if(!empty($header_email)) { $icon = esc_attr($header_email_icon); echo "<li> <span> <i class='fa $icon'></i> </span>"; echo esc_html($header_email); echo "</li>"; } if(!empty($header_phone)) { $ph = esc_attr($header_phone_icon); echo "<li> <span> <i class='fa $ph'></i> </span>"; echo esc_html($header_phone) echo "</li>"; } echo "<a href='$header_phone'>$header_phone</a>"; A bit cleaner to read now. That said I don't know what your anchor is supposed to do with that phone number. It should be some destination rather than a simple phone number, no? And how do you have a separate class for each phone or email value? That space you placed after 'fa' implies a separate classname so I am confused. OK - had to correct the code I tried to replicate. You have some huge issues here. You have a list item that I think you want to show in italics but also using a strange class. I don't think the class is being specified correctly and there is nothing inside the (outdated) italics tag to be shown. Edited January 22, 2023 by ginerjm Removed code for correcting. Quote Link to comment https://forums.phpfreaks.com/topic/315824-clickable-phone-number-and-mail-in-php/#findComment-1604908 Share on other sites More sharing options...
Barand Posted January 22, 2023 Share Posted January 22, 2023 53 minutes ago, ginerjm said: I don't think the class is being specified correctly and there is nothing inside the (outdated) italics tag to be shown. Font Awesome icons EG <i class='fa fa-phone'></i> (123) 555 9876 Quote Link to comment https://forums.phpfreaks.com/topic/315824-clickable-phone-number-and-mail-in-php/#findComment-1604912 Share on other sites More sharing options...
Raf Posted January 22, 2023 Author Share Posted January 22, 2023 (edited) Hello, Well, the code should do the same like this: <a href="tel:123">123</a> <a href="mailto:123@gmail.com">123@gmail.com</a> nothing more. I found it, I consulted with the support, confirmed the correctness of my assumption;) unfortunately, they do not support such changes, (hm) and I want to add a simple in my understanding functionality, clickable phone and mail. I don’t know if their code is correct, I don’t judge it. Is this code above working, tested? Regards Raf Edited January 22, 2023 by Raf Quote Link to comment https://forums.phpfreaks.com/topic/315824-clickable-phone-number-and-mail-in-php/#findComment-1604916 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.