php类操作符 -> 连续访问多个方法实例

<?php

class a{
    private $b = 0;

    public function c( $Num = 0 )
    {  
        $this->b = $Num;  
        return $this;   // 关键就在这里 有这条就可以连续调用了  
    }

    public function d($d)
    {
        $this->b = $this->b+$d;
        return $this;
    }

    public function e()
    {  
        echo $this->b;  
    }  
}

//调用  
$Obj = new a;
$Obj -> c(50) -> d(10)->e();    // 调用运行后 页面会输出60

?>