时间:2021-07-01 10:21:17 帮助过:6人阅读
首先咱先看到例子,最简单不过的执行流程了:
error_reporting(E_ALL); $a = 'I am test.'; $b = & $a; echo $b ."\n"; ?> |
不用说 % php -f gc.php 输出结果非常明了:
hy0kl% php -f gc.php I am test. |
好,下一个:
error_reporting(E_ALL); $a = 'I am test.'; $b = & $a; $b = 'I will change?'; echo $a ."\n"; echo $b ."\n"; ?> |
执行结果依然很明显:
hy0kl% php -f gc.php I will change? I will change? |
君请看:
error_reporting(E_ALL); $a = 'I am test.'; $b = & $a; unset($a); echo $a ."\n"; echo $b ."\n"; ?> |
是不是得想一下下呢?
hy0kl% php -f gc.php Notice: Undefined variable: a in /usr/local/www/apache22/data/test/gc.php on line 8 I am test. |
有点犯迷糊了吗?
君再看:
error_reporting(E_ALL); $a = 'I am test.'; $b = & $a; unset($b); echo $a ."\n"; echo $b ."\n"; ?> |
其实如果 Example 3 理解了,这个与之异曲同工.
hy0kl% php -f gc.php I am test. Notice: Undefined variable: b in /usr/local/www/apache22/data/test/gc.php on line 9 |
君且看:
error_reporting(E_ALL); $a = 'I am test.'; $b = & $a; $a = null; echo '$a = '. $a ."\n"; echo '$b = '. $b ."\n"; ?> |
猛的第一感觉是什么样的?
hy0kl% php -f gc.php $a = $b = |
error_reporting(E_ALL); $a = 'I am test.'; $b = & $a; $b = null; echo '$a = '. $a ."\n"; echo '$b = '. $b ."\n"; ?> |
OK,如果上面的例子的结果对看官来说无任何细节可言,那您可关闭本窗口了,欢迎有空再来!