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