在翻看 PHP 手册的时候看到关于伪变量的内容,其中有一份示例代码:
foo();
// Note: the next line will issue a warning if E_STRICT is enabled.
A::foo();
$b = new B();
$b->bar();
// Note: the next line will issue a warning if E_STRICT is enabled.
B::bar();
?>
5.6.30 版本下运行结果是
$this is defined (A)
$this is not defined.
$this is defined (B)
$this is not defined.
7.0.9 版本下运行结果是
$this is defined (A)
$this is not defined.
$this is not defined.
$this is not defined.
我是在 PHPStorm 下切换版本运行的,也在一个代码在线运行网站运行代码,也是这个结果。
有了解的同学解答一下吗?谢谢!
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
闭关修行中......