I need a simple php if statement that checks if anything is assigned to a variable. If the variable is empty I don’t want anything to display but if is there is something assigned to the variable I would like a line of html to be displayed.
Right now, the html is displayed whether the variable is assigned a value or not. Here is the if statement:
if(!isset($twitter)) {
echo '';
} else {
echo '<li><a href="http://twitter.com/' . $twitter . '"><span class="ss-twitter ss-icon" style="background-color:' . $iconbgcolor . '; color:' . $iconcolor . '">L</span></a>';
}
If you want to see the rest of the code for the project is found here.
I have also tried using the empty function but that wouldn’t work either.
Variable is always exists
Try: