Home >Backend Development >PHP Tutorial >php class的问题

php class的问题

WBOY
WBOYOriginal
2016-06-23 13:34:33815browse

class xueshen{
public $name;
        public $money;
public  function wowo(){
   echo $this->name;
}

}

$xiao = new xueshen;
$xiao->name='girl';


这里面的name 不用加上$符号吗?:($xiao->name='girl';),不应该是:$xiao->$name='girl';。


回复讨论(解决方案)

这里的name不用加$
因为是对象引用
$xiao是对象,name是对象的属性,而不是变量,所以不用$
$xiao->name

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