84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
PHP global 关键字
global 关键字用于函数内访问全局变量。
在函数内调用函数外定义的全局变量,我们需要在函数中的变量前加上 global 关键字:
实例
$x=5;$y=10;function myTest(){global $x,$y;$y=$x+$y;}myTest();echo $y; // 输出 15?>
输出15这里应该是输出10,myTest()这里不能输出,应该加上一句echo $y
Okay thanks for the feedback!
Okay thanks for the feedback!