This question shows research effort; it is useful and clear
0
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
以下代码输出 1,但为什么呢?该属性是私有的,子类不应访问它。
<?php
trait PropertiesTrait {
private $same = true;
}
class PropertiesExample {
use PropertiesTrait;
public function foo(){
echo $this->same;
}
}
(new PropertiesExample())->foo();
?>