PHP - If variable is not empty echo some html code

0 votes

I want to display some HTML code if a variable is not empty if not it should display nothing.

This is what I tried but didnt work:

<?php 
    $web = the_field('website');
    if (isset($web)) {
?>
       <span class="field-label">Website: </span><a href="http://<?php the_field('website'); ?>" target="_blank"><?php the_field('website'); ?></a> 
<?php
    } else { 
        echo "Niente";
    }
?>

Can someone help me do this?

Jun 4, 2022 in PHP by Kichu
• 19,050 points
634 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to check if php session is already started or not?

Hello kartik, Use session_id(), it returns an empty string ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,880 points
5,142 views
0 votes
1 answer

How do check if a PHP session is empty?

Hii, I would use isset and empty: session_start(); if(isset($_SESSION['blah']) && !empty($_SESSION['blah'])) { ...READ MORE

answered Nov 9, 2020 in PHP by Niroj
• 82,880 points
8,818 views
0 votes
1 answer

How can I use PHP to check if a directory is empty?

Hello @kartik, It seems that you need scandir instead of ...READ MORE

answered Nov 10, 2020 in PHP by Niroj
• 82,880 points
8,809 views
0 votes
0 answers

Using if(isset($_POST['submit'])) to not display echo when script is open is not working

I'm running into a small issue with ...READ MORE

Aug 1, 2022 in PHP by Kithuzzz
• 38,010 points
2,279 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19, 2020 in PHP by Niroj
• 82,880 points
856 views
0 votes
0 answers

PHP - If variable is not empty, echo some html code

If a variable is not empty, I ...READ MORE

Jul 24, 2022 in HTML by Ashwini
• 5,430 points
818 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
9,671 views
0 votes
1 answer

Vertically centering text in a div

Try this code: .smallUnitBox { ...READ MORE

answered Sep 3, 2018 in Blockchain by digger
• 26,740 points
593 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP