是否可以在 for 循环中调用函数?我有许多完全相同的数据库,我想使用 for 循环一次设置一个连接(35 个数据库)。我无法让 php 声明名称中带有变量的函数。
for ($i = 1; $i <= 35; $i++)
{
$j=$i+2;
echo "<br><br>DB $i";
$connection$j = prodDB$i();
$getFromDB = "select URL, count(id) as counts from ProductList GROUP BY URL";
$NamesReturned = mysqli_query($connection$j,$getFromDB) or die("Can't execute query GFNFDB.<br><br>$getFromDB<br><br>");
while ($ret=mysqli_fetch_array($NamesReturned))
{
$DB$icounts=$ret["counts"];
$URL=$ret["URL"];
echo "<br>$DB$icounts -- $URL";
}
echo "<br>$DB$icounts";
}