我有一个应该运行mysql查询并返回$ output的函数。当我在函数中回显变量时,变量打印正确,但如果我尝试在主代码中打印$schoolNamesListEngland
,它只显示0。
while ($preparedStatement->fetch())
{
echo $id . " " . $name . "<br>";
$output += "<option value='" . $id . "'>" . $name . "</option>";
}
$output += "</select>";
return $output;
函数调用:
$schoolNamesListEngland = getSchoolList($connection, "England");
答案 0 :(得分:2)
Jast将$output += "</select>";
替换为$output .= "</select>";