Home  >  Article  >  Backend Development  >  PHP private 有关问题《新手求教》

PHP private 有关问题《新手求教》

WBOY
WBOYOriginal
2016-06-13 12:36:42768browse

PHP private 问题《新手求教》
class Pc{
 private $name;

function __construct($pcName){
$this->name=$pcName;
}
}

我想问为什么在方法中访问private的name需要用$this或者self,我直接用$name不行么?我把$this->name改为$name就有问题!不是private修饰的本类内部都可以访问么?求高手给个详细的解答,谢了

php private
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article: 问下解决思路 Next article: 多表联系关系调用