如果在数据库中为空,我怎样才能使twitter和facebook链接不显示?
这是我的代码:
<?php
$links=explode(" ",preg_replace("|\s|Umxis", ' ', $r['web_links']));
if(count($links)>0){
echo "<div id='profile_links'>
<h3>Websites:</h3>
<ul class='profile_links'>";
foreach($links as $k=>$v){
echo "<li><a href='$v'>$v</a></li>";
}
echo "</ul>
</div>
<a class='fb_link' href='http://{$r['facebook']}'</a>
<a class='tw_link' href='http://www.twitter.com/{$r['twitter']}'</a>";
}
?>
答案 0 :(得分:0)
isset怎么样?!
<?php
$links=explode(" ",preg_replace("|\s|Umxis", ' ', $r['web_links']));
if(count($links)>0){
echo "<div id='profile_links'>
<h3>Websites:</h3>
<ul class='profile_links'>";
foreach($links as $k=>$v){
echo "<li><a href='$v'>$v</a></li>";
}
echo "</ul>
</div>";
if (isset($r['facebook']) && ! empty($r['facebook'])) {
echo "<a class='fb_link' href='http://{$r['facebook']}'</a>";
}
if (isset($r['facebook']) && ! empty($r['facebook'])) {
echo "<a class='tw_link' href='http://www.twitter.com/{$r['twitter']}'</a>";
}
}
?
&GT;