【发布时间】:2013-03-08 18:32:35
【问题描述】:
为什么会这样?我的意思是,访问私有变量。
类测试{ 私人 $q = 0; 公共函数 __construct() { $this->q = 1; } 公共静态函数 EpicConstruct() { $test = 新的自我(); $test->q = 2; 返回$测试; } } $test = Test::EpicConstruct();【问题讨论】:
-
因为你是从同一个类访问它。
-
把它想象成男女更衣室。同一个类的对象可以看到彼此的private。
标签: php oop static-methods