PHP中引用类的属性

在一个类中,可以访问一个特殊的指针--$this。如果当前类的一个属性为$attribute,则当在该类中通过一个操作设置或访问该变量时,可以使用$this->attribute来引用。

class classname
{
    public $attribute;
    function operation($param)
    { 
         $this->attibute = $param
          echo $this->attribute;
    }
}

 

posted @ 2017-05-15 22:57  小Y爱学前端  阅读(832)  评论(0编辑  收藏  举报