abstract class Mage_Core_Model_Mysql4_Abstract extends Mage_Core_Model_Resource_Abstract
{
                                                           .
                                                           .
                                                           .
                                                     方法省略    protected function _afterDelete(Mage_Core_Model_Abstract $object)
    {
        return $this;
    }
}
$this在php都有些什么作用??
除了调用本类方法/变量意外还有吗?
此段程序的$this返回的是下面的哪个类???理由是什么。帮忙研究下吧,从来没遇到这种返回方式,谢谢。
1,Mage_Core_Model_Mysql4_Abstract
2,Mage_Core_Model_Resource_Abstract
3,Mage_Core_Model_Abstract 

解决方案 »

  1.   

    $this指类Mage_Core_Model_Mysql4_Abstract 的当前对象。
      

  2.   

    $this代表类的实例化对象,相当实例化对象的内部指针,而不是类本身.
      

  3.   

    如果调用echo $this;
    起不是没有任何输出???
      

  4.   

    class a
    {
      function abc()
      {
         echo $this;
      }
    }
    a::abc();//空,因为$this无所指。
    $a = new a();
    $a->abc();//object,因为$this相当于$a的内部指针。
      

  5.   

    4楼运行的你代码,出现下列错误。
    Catchable fatal error: Object of class a could not be converted to string in /var/www/duixiang.php on line 6
      

  6.   

    a::abc();这个没有错,但是$a = new a();  $a->abc();貌似错了
      

  7.   

    你的php版本比我新.
    大概就是那个意思.
    class a
    {
      public $name = 'hello world!';
      function abc()
      {
     if($this) echo $this->name;
      }
    }
    a::abc();//空,因为$this无所指。
    $a = new a();
    $a->abc();//hello world,因为$this相当于$a的内部指针。
      

  8.   

    哈哈,其实这样写没错,这是php的bug!!!
      

  9.   

    想问的是$this到底是输出哪个里面的
      

  10.   

    $this指类Mage_Core_Model_Mysql4_Abstract 的当前实例化对象。