我必须在我的主页上打印这些新闻。在我设置的 index.php 文件中,在下面包含此文件,但没有返回任何内容...错误在哪里?该脚本从文件中获取消息。然后它将每个新闻设置为一个字符串。然后该函数为每个新闻创建一个“标准”回显然后打印新闻。
但是什么都没有打印...
谢谢大家!
<?php
if (file_exists("./public/ita/news/news.txt")) {
$getnews1 = "./public/ita/news/news.txt";
$news1 = file($getnews1); //file in to an array
}
if (file_exists("./public/ita/news/news2.txt")) {
$getnews2 = "./public/ita/news/news2.txt";
$news2 = file($getnews2); //file in to an array
}
if (file_exists("./public/ita/news/news3.txt")) {
$getnews3 = "./public/ita/news/news3.txt";
$news3 = file($getnews3); //file in to an array
}
if (file_exists("./public/ita/news/news4.txt")) {
$getnews4 = "./public/ita/news/news4.txt";
$news4 = file($getnews4); //file in to an array
}
if (file_exists("./public/ita/news/news5.txt")) {
$getnews5 = "./public/ita/news/news5.txt";
$news5 = file($getnews5); //file in to an array
}
function post_news()
{
echo '<div align="left" class="newstitle">';
echo $news[0];
echo '</div>';
echo '<div align="left" class="news">';
echo '<p></p>';
echo $news[1];
echo $news[2];
echo $news[3];
echo $news[4];
echo $news[5];
echo $news[6];
echo $news[7];
echo $news[8];
echo $news[9];
echo $news[10];
echo $news[11];
echo '</div>';
}
if($news1 != NULL) {
$news = $news1;
post_news();
}
if($news2 != NULL) {
$news = $news2;
post_news();
}
if($news3 != NULL) {
$news = $news3;
post_news();
}
?>