Tryng获取第一个代码的代码位置!
$fetchcategory = $results['category'];
$string = array ( '/\b(.*?)\b/i' );
$replace = array ( '<a href="?inav=category&category=$1">$1</a>' );
$category = preg_replace($string, $replace, $fetchcategory);
echo '<p class="news_cat" /><p class="news_date"><img title="News category!" dir="ltr" src="img/category.png" style="width: 13px; height: 13px;" /> Category: '.$category.'</p>';
echo '</p>';
这是我想要显示的第一个代码
的代码 echo '<p class="news_date"><img title="Date added!" dir="ltr" src="img/info_date.png" style="width: 13px; height: 13px;" /> ';
$timestamp = $results['timestamp'];
$date = strtotime($timestamp);
echo $postdate = date("d.m.Y",$date);
答案 0 :(得分:0)
您必须编辑PHP,以便同时回显日期和类别的信息。在包含类news_date
的段落中,让我们看一下类别
echo '<p class="news_cat" />'.
'<p class="news_date">'.
'<img title="News category!" dir="ltr" src="img/category.png" style="width: 13px; height: 13px;" />'.
'Category: '.$category.
'</p>';
日期代码
$timestamp = $results['timestamp'];
$date = strtotime($timestamp);
echo '<p class="news_date">'.
'<img title="Date added!" dir="ltr" src="img/info_date.png" style="width: 13px; height: 13px;" />';
echo $postdate = date("d.m.Y",$date);
// Missing end thag for paragraph!
echo '</p>';
如果我们将它们合并在一起,我们会得到类似的结果:
$timestamp = $results['timestamp'];
$date = strtotime($timestamp);
echo '<p class="news_date">'.
'<img title="Date added!" dir="ltr" src="img/info_date.png" style="width: 13px; height: 13px;" />';
echo $postdate = date("d.m.Y",$date);
echo '<img title="News category!" dir="ltr" src="img/category.png" style="width: 13px; height: 13px;" />'.
'Category: '.$category.
// Missing end tag for paragraph!
'</p>';
然后输出是这样的:
<p class="news_date">
<img dir="ltr" src="img/info_date.png" style="width: 13px; height: 13px;" title="Date added!">
20.08.2015
<img class="" dir="ltr" src="img/category.png" style="width: 13px; height: 13px;" title="News category!">
Category:
<a href="?inav=category&category="></a>
<a href="?inav=category&category=Film">Film</a>
<a href="?inav=category&category="></a>
</p>
在页面上你会得到这样的结果:
而不是:
正如您所看到的,通过简单地将php和输出分成几行进行调试,它变得更加清晰。我们甚至发现自己是一个没有结尾标记的段落,但修复了它。