我有一个名为kal_test.php
的php文件,它给变量$vbl
赋值。这个变量在名为kal_generator.php
的文件中需要,该文件从该变量生成表格(我会省略细节)。具体如下:
[kal_test.php]
<?php
$vbl = "14/09/2011";
include ("kal_generator.php");
?>
[kal_test.php]
<?php
// Long code converts the $vbl into a 2-dimensional array called $output
// I'll spare you the details (it works fine by the way)
?>
<table>
<tr><th>bla</th><th>blabla</th></tr>
<?php
foreach ($output as $v1) {
echo "<tr>";
foreach ($v1 as $v2) {
echo "<td>$v2</td>";
}
echo "</tr>\n";
}
?>
</table>
这个设置很好用,但是我不能在同一页上展示两个这样的网页,就像这样:
[kal_test.php]
。<?php
$vbl = "14/09/2011";
include ("kal_generator.php");
$vbl = "21/09/2011";
include ("kal_generator.php");
?>
这将产生以下结果:
//here comes the header
<table> // table created with $vbl = "14/09/2011"
<tr><th>bla</th><th>blabla</th></tr>
<tr><td>this</td><td>works</td></tr>
<tr><td>this</td><td>works</td></tr>
</table>
//here should the second table be and also the rest of the page (footer), this is completely missing
我做错了什么?谢谢!
function
关键字和几个括号把它包起来有什么难的吗?或许你应该考虑把那个函数分成几个函数。 - Brad