<!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>
After execution, the result is 6, shouldn’t it be 11? I checked that $x has no value
You only used the value of the global variable in the method, and the value of the global variable did not change.
Use the $GLOBAL super global function to print the data and you will know how much the data is