我有一个config.php
包含一些常量和方法的文件。
我有一个test.php
文件,它调用config.php
.
相关代码为:
$Questions = array(
1 => "Is he/she nice?1",
2 => "Is he/she sweet?2",
3 => "Is he/she nice?3",
4 => "Is he/she sweet?4",
5 => "Is he/she nice?5",
6 => "Is he/she sweet?6",
7 => "Is he/she nice?7",
8 => "Is he/she sweet?8",
9 => "Is he/she nice?9",
10 => "Is he/she sweet?10"
);
function PrintAnswersOnMe($uid)
{
$uid = antiSQLi($uid);
$query = "SELECT * FROM AnsAns WHERE fid='".$uid."'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$rrr = $row[2];
echo $Questions[1];
echo $rrr . ' ' . $Questions[$rrr];
echo "You'r friend <img src='http://graph.facebook.com/".$row['uid']."/picture/' /> answered " . (($row['answer'] == 1) ? "yes" : "no") . " about wether you're ". $rrr.": " . $Questions[$rrr];
echo "<br /> " . $Questions['2'] . "<br/>";
}
}
该test
文件仅调用PrintAnswersOnMe
. (它包括它)
一切正常的文件,除了没有 $Question[...]
评估到实际的 HTML 输出!
为了检查这一点,我添加了$Questions[2]
- 而且$Questions['2']
- 它们都没有产生 HTML 输出。该循环确实执行了,因为其他所有内容都进入了 HTML。
有趣的是,它内部test.php
确实有效——echo $Questions[...]
实际上是产品到 HTML 输出。有人知道这种神秘的行为吗?