我正在为Question2Answer制作一个插件,因为我正在收到警告
警告:无法修改标头信息 - 已在/ home / name中发送的标头(在/home/name/public_html/test/qa-plugin/welcome-widget/qa-welcome-widget.php:2中开始输出)第767行/public_html/test/qa-include/qa-page.php
我搜索了它,发现在内容类型或编码之前出现空白或呈现HTML可能是一个问题。我试图通过所有这些选项,但无法弄清楚问题。如果可能的话,请指出正确的方向。
这是代码:'
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo qa_path_to_root() ?>/qa-plugin/Welcome-Widget/welcome-widget.css">
<script type="text/javascript" href="<?php echo qa_path_to_root() ?>/qa-plugin/Welcome-Widget/js/qa-welcome-widget.js"></script>
<?php
class qa_welcome_widget {
function allow_template($template)
{
return true;
}
function allow_region($region)
{
return true;
}
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
echo '<div class="ww-wrapper">';
echo '<p id="ww-heading">'.qa_lang_html('plugin_ww/heading_option').'</p>';
echo '<table class="ww-box">';
echo '<tr>';
echo '<td class="ww-question"><i class="fa fa-question-circle" aria-hidden="true"></i>';
echo '<p>'.qa_lang_html('plugin_ww/first_option').'</p>';
echo '<p><a href="/ask" class="ww-button">Ask a Question</a></p></td>';
echo '<td class="ww-reply"><i class="fa fa-comment" aria-hidden="true"></i>';
echo '<p>'.qa_lang_html('plugin_ww/second_option').'</p>';
echo '<p><a href="/questions" class="ww-button">View Questions</a></p></td>';
echo '<td class="ww-vote"><i class="fa fa-thumbs-up" aria-hidden="true"></i>';
echo '<p>'.qa_lang_html('plugin_ww/third_option').'</p>';
echo '<p><a href="/questions" class="ww-button">View Questions</a></p></td>';
echo '</tr>';
echo '</table>';
echo '</div>';
echo '<ul class="ww-topnav" id="ww-myTopnav">
<li><p>Menu -></p></li>
<li><a href="/questions">Recent</a></li>
<li><a href="/hot">Hot</a></li>
<li><a href="/questions?sort=votes">Most Votes</a></li>
<li><a href="questions?sort=answers">Most Answers</a></li>
<li><a href="questions?sort=views">Most Views</a></li>
<li class="icon">
<a href="javascript:void(0);" onclick="myFunction()">☰</a>
</li>
</ul>';
}
}
对于完整的代码,您可以在Github上看到该插件。