how do i set a conditional statement here?
<ul>
<li class="artist-website"><a href="<?php=$artist_website?>" target="_blank"></a></li>
<li class="artist-youtube"><a href="http://youtube.com/<?php=$artist_youtube?>" target="_blank"></a></li>
<li class开发者_JAVA百科="artist-twitter"><a href="http://twitter.com/<?php=$artist_twitter?>" target="_blank"></a></li>
</ul>
I want to add an if exists statement before each of the 'li' items. For example, if "artist-website" exists, then echo <li class="artist-website"><a href="<?php=$artist_website?>" target="_blank"></a></li>
How can I do make this work?
<ul>
<?php if(isset($artist_website){ ?> <li class="artist-website">...</li> <?php } ?>
...
</ul>
Or if(!empty($artist_website))
, depending how your variables are setup.
As simple as:
<?php if (/* exists */) : ?>
<li class="artist-website"><a href="<?php echo $artist_website ?>" target="_blank"></a></li>
<?php endif; ?>
Ah, I understand what you're asking. Here is a link showing how to check if a website is available. The other 2 comments mainly showed you how to set up the if statement.
http://css-tricks.com/snippets/php/check-if-website-is-available/
EDIT: unless you are checking if a variable is set or not... then it would be:
if (isset($var)) {
// do this
}
精彩评论