$num = 39; //sets number of weeks - there are only 38 rounds so 39 is fine
$num2 = $num-1; //for adding the previous weeks table - rest of code not added yet
while($num > 0) // set to 0 so that when it reaches week 1 it stops
{
if ( file_exists('./results/week'.$num.'.html'))
{
echo '<h1>week '.$num.'</h1>';
echo (include_once('./results/week'.$num.'.html'));
$num = $num - 1;
}
else
{
$num = $num - 1;
}
}
嗨 我正在尝试向页面添加多个表格(html 文件),此代码似乎可以工作,但是它会在每个表格的末尾添加一个 1,所以我得到:
Week 3
Name Result
John 4
Bob 3
1
Week 2
Name Result
Bob 6
John 1
1
等等。 请问哪位好心人可以告诉我这个1是从哪里来的吗?以及如何摆脱它? 我将不胜感激。 塔里奇
最佳答案
不要echo include_once
,只需include_once
。 1 是 include_once
调用的 echo
ed 返回值。
关于PHP include_once 添加尾随 1 到页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9387585/