所以循环不打印,我不明白为什么?我只是一个初学者,所以我很困惑它为什么不起作用。如果你们可以解释它背后的原因,那太棒了。用于循环的PHP函数。不打印循环
<html>
<body>
<?php
$numbers = array(4,6,2,22,11);
sort($numbers);
function printarray($numbers, $x) {
$countarray = count($numbers);
for($x = 0; $x < $countarray; $x++) {
echo $numbers[$x];
echo "<br>";
}
}
printarray();
?>
</body>
</html>
查看可变范围http://php.net/manual/en/language.variables.scope.php。您未通过'$ numbers' .. – chris85
另一个可以通过介绍性教程解决的问题... –
[PHP变量作用域]的可能重复(http://stackoverflow.com/questions/1781780/php-可变范围),或者http://stackoverflow.com/questions/16959576/reference-what-is-variable-scope-which-variables-are-accessible-from-where-and。 – chris85