<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php.cn</title>
< /head>
<body>
<?php
$x=5;
$y=6;
function test(){
global $x,$y;
$y= $x+$y;
}
test();
echo $y;
?>
</body>
</html>
Nach der Ausführung ist das Ergebnis 6, was sollte nicht 11 sein? Ich habe $x überprüft und es gibt keinen Wert
你只是方法里使用了全局变量的值,全局变量的值并没有改变的
使用 $GLOBAL 超全局函数 打印下数据就知道数据在是多少了