你好,有人能帮我做点什么吗?我有这个代码:
<?php if($hashtagExist == true): ?>
<?php foreach($resultsTags as $tag): ?>
<a href="results.php?tag=<?php echo str_replace("#", "",$tag["Tags"]); ?>" name="tag" class="tags-post"><?php echo $tag["Tags"];?></a>
<?php endforeach; ?>
<?php else: ?>
<a href=""></a>
<?php endif; ?>
我正在测试打印标签的功能,所以如果有标签,它会把它放在标签中。结果是正确的,但<a href>
不是一个可点击的链接,只是纯文本,我找不到解决方案。
我更喜欢使用php来回显html,而不是将php嵌入到html标记或属性中。。。
<?php
if($hashtagExist == true){
foreach($resultsTags as $tag){
$unhash = str_replace("#","",$tag); //Removes the hashes
echo '<a href="results.php?tag='.$unhash.'" name="tag" class="tags-post">'.$unhash.'</a>'; //Display link with removed hashes
echo '<a href="results.php?tag='.$unhash.'" name="tag" class="tags-post">'.$tag.'</a>'; //Retains the name of the hash with hash before the name i.e #hash
$out .= '<a href="results.php?tag='.$unhash.'" name="tag" class="tags-post">'.$unhash.'</a>'; //in case you want to use this between some other tags
}
} else {
$out = '<a href=""></a>';
}
echo $out; //result variable can be used anywhere in the page
?>